接口 Context

所有超级接口:
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
  • 方法详细资料

    • getInputTopics

      Collection<String> getInputTopics()
      Get a list of all input topics.
      返回:
      a list of all input topics
    • getOutputTopic

      String getOutputTopic()
      Get the output topic of the source.
      返回:
      output topic name
    • getCurrentRecord

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

      String getOutputSchemaType()
      Get output schema builtin type or custom class name.
      返回:
      output schema builtin type or custom class name
    • getFunctionName

      String getFunctionName()
      The name of the function that we are executing.
      返回:
      The Function name
    • getFunctionId

      String getFunctionId()
      The id of the function that we are executing.
      返回:
      The function id
    • getFunctionVersion

      String getFunctionVersion()
      The version of the function that we are executing.
      返回:
      The version id
    • getUserConfigMap

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

      Optional<Object> getUserConfigValue(String key)
      Get any user-defined key/value.
      参数:
      key - The key
      返回:
      The Optional value specified by the user for that key.
    • getUserConfigValueOrDefault

      Object getUserConfigValueOrDefault(String key, Object defaultValue)
      Get any user-defined key/value or a default value if none is present.
      参数:
      key - the config key to retrieve
      defaultValue - value returned if the key is not found
      返回:
      Either the user config value associated with a given key or a supplied default value
    • getPulsarAdmin

      PulsarAdmin getPulsarAdmin()
      Get the pulsar admin client.
      返回:
      The instance of pulsar admin client
    • publish

      @Deprecated <X> CompletableFuture<Void> publish(String topicName, X object, String schemaOrSerdeClassName)
      已过时。
      Publish an object using serDe or schema class for serializing to the topic.
      参数:
      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
      返回:
      A future that completes when the framework is done publishing the message
    • publish

      @Deprecated <X> CompletableFuture<Void> publish(String topicName, X object)
      已过时。
      Publish an object to the topic using default schemas.
      参数:
      topicName - The name of the topic for publishing
      object - The object that needs to be published
      返回:
      A future that completes when the framework is done publishing the message
    • newOutputMessage

      <X> TypedMessageBuilder<X> newOutputMessage(String topicName, Schema<X> schema) throws PulsarClientException
      New output message using schema for serializing to the topic.
      类型参数:
      X - the type of message
      参数:
      topicName - The name of the topic for output message
      schema - provide a way to convert between serialized data and domain objects
      返回:
      the message builder instance
      抛出:
      PulsarClientException - if an error occurs
    • newConsumerBuilder

      <X> ConsumerBuilder<X> newConsumerBuilder(Schema<X> schema) throws PulsarClientException
      Create a ConsumerBuilder with the schema.
      类型参数:
      X - the message type of the consumer
      参数:
      schema - provide a way to convert between serialized data and domain objects
      返回:
      the consumer builder instance
      抛出:
      PulsarClientException - if an error occurs
    • newOutputRecordBuilder

      <X> FunctionRecord.FunctionRecordBuilder<X> newOutputRecordBuilder(Schema<X> schema)
      Creates a FunctionRecordBuilder initialized with values from this Context. It can be used in Functions to prepare a Record to return with default values taken from the Context and the input Record.
      类型参数:
      X - the message type of record builder
      参数:
      schema - provide a way to convert between serialized data and domain objects
      返回:
      the record builder instance