Interface WindowContext


@Public @Stable public interface WindowContext
  • Method Details

    • getTenant

      String getTenant()
      The tenant this function belongs to.
      Returns:
      the tenant this function belongs to
    • getNamespace

      String getNamespace()
      The namespace this function belongs to.
      Returns:
      the namespace this function belongs to
    • getFunctionName

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

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

      int getInstanceId()
      The id of the instance that invokes this function.
      Returns:
      the instance id
    • getNumInstances

      int getNumInstances()
      Get the number of instances that invoke this function.
      Returns:
      the number of instances that invoke this function.
    • getFunctionVersion

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

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

      String getOutputTopic()
      Get the output topic of the function.
      Returns:
      output topic name
    • getOutputSchemaType

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

      org.slf4j.Logger getLogger()
      The logger object that can be used to log in a function.
      Returns:
      the logger object
    • incrCounter

      void incrCounter(String key, long amount)
      Increment the builtin distributed counter referred by key.
      Parameters:
      key - The name of the key
      amount - The amount to be incremented
    • getCounter

      long getCounter(String key)
      Retrieve the counter value for the key.
      Parameters:
      key - name of the key
      Returns:
      the amount of the counter value for this key
    • putState

      void putState(String key, ByteBuffer value)
      Update the state value for the key.
      Parameters:
      key - name of the key
      value - state value of the key
    • getState

      ByteBuffer getState(String key)
      Retrieve the state value for the key.
      Parameters:
      key - name of the key
      Returns:
      the state value for the key.
    • getUserConfigMap

      Map<String,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

      Optional<Object> getUserConfigValue(String key)
      Get any user-defined key/value.
      Parameters:
      key - The key
      Returns:
      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.
      Parameters:
      key - the config key to retrieve
      defaultValue - value returned if the key is not found
      Returns:
      Either the user config value associated with a given key or a supplied default value
    • recordMetric

      void recordMetric(String metricName, double value)
      Record a user defined metric.
      Parameters:
      metricName - The name of the metric
      value - The value of the metric
    • publish

      <T> CompletableFuture<Void> publish(String topicName, T object, String schemaOrSerdeClassName)
      Publish an object using serDe 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

      <T> CompletableFuture<Void> publish(String topicName, T object)
      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