Interface Context

  • All Superinterfaces:
    BaseContext

    @Public
    @Stable
    public interface Context
    extends BaseContext
    Context provides contextual information to the executing function. Features like which message id we are handling, whats the topic name of the message, what are our operating constraints, etc can be accessed by the executing function
    • Method Detail

      • getInputTopics

        java.util.Collection<java.lang.String> getInputTopics()
        Get a list of all input topics.
        Returns:
        a list of all input topics
      • getOutputTopic

        java.lang.String getOutputTopic()
        Get the output topic of the source.
        Returns:
        output topic name
      • getCurrentRecord

        Record<?> getCurrentRecord()
        Access the record associated with the current input value.
        Returns:
      • getOutputSchemaType

        java.lang.String getOutputSchemaType()
        Get output schema builtin type or custom class name.
        Returns:
        output schema builtin type or custom class name
      • getFunctionName

        java.lang.String getFunctionName()
        The name of the function that we are executing.
        Returns:
        The Function name
      • getFunctionId

        java.lang.String getFunctionId()
        The id of the function that we are executing
        Returns:
        The function id
      • getFunctionVersion

        java.lang.String getFunctionVersion()
        The version of the function that we are executing.
        Returns:
        The version id
      • getUserConfigMap

        java.util.Map<java.lang.String,​java.lang.Object> getUserConfigMap()
        Get a map of all user-defined key/value configs for the function.
        Returns:
        The full map of user-defined config values
      • getUserConfigValue

        java.util.Optional<java.lang.Object> getUserConfigValue​(java.lang.String key)
        Get any user-defined key/value.
        Parameters:
        key - The key
        Returns:
        The Optional value specified by the user for that key.
      • getUserConfigValueOrDefault

        java.lang.Object getUserConfigValueOrDefault​(java.lang.String key,
                                                     java.lang.Object defaultValue)
        Get any user-defined key/value or a default value if none is present.
        Parameters:
        key -
        defaultValue -
        Returns:
        Either the user config value associated with a given key or a supplied default value
      • getPulsarAdmin

        org.apache.pulsar.client.admin.PulsarAdmin getPulsarAdmin()
        Get the pulsar admin client.
        Returns:
        The instance of pulsar admin client
      • publish

        <O> java.util.concurrent.CompletableFuture<java.lang.Void> publish​(java.lang.String topicName,
                                                                           O object,
                                                                           java.lang.String schemaOrSerdeClassName)
        Deprecated.
        Publish an object using serDe or schema class for serializing to the topic.
        Parameters:
        topicName - The name of the topic for publishing
        object - The object that needs to be published
        schemaOrSerdeClassName - Either a builtin schema type (eg: "avro", "json", "protobuf") or the class name of the custom schema class
        Returns:
        A future that completes when the framework is done publishing the message
      • publish

        <O> java.util.concurrent.CompletableFuture<java.lang.Void> publish​(java.lang.String topicName,
                                                                           O object)
        Deprecated.
        Publish an object to the topic using default schemas.
        Parameters:
        topicName - The name of the topic for publishing
        object - The object that needs to be published
        Returns:
        A future that completes when the framework is done publishing the message
      • newOutputMessage

        <O> org.apache.pulsar.client.api.TypedMessageBuilder<O> newOutputMessage​(java.lang.String topicName,
                                                                                 org.apache.pulsar.client.api.Schema<O> schema)
                                                                          throws org.apache.pulsar.client.api.PulsarClientException
        New output message using schema for serializing to the topic
        Type Parameters:
        O -
        Parameters:
        topicName - The name of the topic for output message
        schema - provide a way to convert between serialized data and domain objects
        Returns:
        the message builder instance
        Throws:
        org.apache.pulsar.client.api.PulsarClientException
      • newConsumerBuilder

        <O> org.apache.pulsar.client.api.ConsumerBuilder<O> newConsumerBuilder​(org.apache.pulsar.client.api.Schema<O> schema)
                                                                        throws org.apache.pulsar.client.api.PulsarClientException
        Create a ConsumerBuilder with the schema.
        Type Parameters:
        O -
        Parameters:
        schema - provide a way to convert between serialized data and domain objects
        Returns:
        the consumer builder instance
        Throws:
        org.apache.pulsar.client.api.PulsarClientException