@InterfaceAudience.Public @InterfaceStability.Stable public interface Context
| Modifier and Type | Method and Description |
|---|---|
void |
deleteState(String key)
Delete the state value for the key.
|
CompletableFuture<Void> |
deleteStateAsync(String key)
Delete the state value for the key, but don't wait for the operation to be completed
|
long |
getCounter(String key)
Retrieve the counter value for the key.
|
CompletableFuture<Long> |
getCounterAsync(String key)
Retrieve the counter value for the key, but don't wait
for the operation to be completed
|
Record<?> |
getCurrentRecord()
Access the record associated with the current input value.
|
String |
getFunctionId()
The id of the function that we are executing
|
String |
getFunctionName()
The name of the function that we are executing.
|
String |
getFunctionVersion()
The version of the function that we are executing.
|
Collection<String> |
getInputTopics()
Get a list of all input topics.
|
int |
getInstanceId()
The id of the instance that invokes this function.
|
org.slf4j.Logger |
getLogger()
The logger object that can be used to log in a function.
|
String |
getNamespace()
The namespace this function belongs to.
|
int |
getNumInstances()
Get the number of instances that invoke this function.
|
String |
getOutputSchemaType()
Get output schema builtin type or custom class name.
|
String |
getOutputTopic()
Get the output topic of the function.
|
PulsarAdmin |
getPulsarAdmin()
Get the pulsar admin client.
|
PulsarAdmin |
getPulsarAdmin(String clusterName)
Get the pulsar admin client by cluster name.
|
String |
getSecret(String secretName)
Get the secret associated with this key.
|
ByteBuffer |
getState(String key)
Retrieve the state value for the key.
|
CompletableFuture<ByteBuffer> |
getStateAsync(String key)
Retrieve the state value for the key, but don't wait for the operation to be completed
|
<S extends StateStore> |
getStateStore(String name)
Get the state store with the provided store name in the function tenant & namespace.
|
<S extends StateStore> |
getStateStore(String tenant,
String ns,
String name)
Get the state store with the provided store name.
|
String |
getTenant()
The tenant this function belongs to.
|
Map<String,Object> |
getUserConfigMap()
Get a map of all user-defined key/value configs for the function.
|
Optional<Object> |
getUserConfigValue(String key)
Get any user-defined key/value.
|
Object |
getUserConfigValueOrDefault(String key,
Object defaultValue)
Get any user-defined key/value or a default value if none is present.
|
void |
incrCounter(String key,
long amount)
Increment the builtin distributed counter referred by key.
|
CompletableFuture<Void> |
incrCounterAsync(String key,
long amount)
Increment the builtin distributed counter referred by key
but dont wait for the completion of the increment operation
|
<O> ConsumerBuilder<O> |
newConsumerBuilder(Schema<O> schema)
Create a ConsumerBuilder with the schema.
|
<O> TypedMessageBuilder<O> |
newOutputMessage(String topicName,
Schema<O> schema)
New output message using schema for serializing to the topic
|
<O> TypedMessageBuilder<O> |
newOutputMessage(String clusterName,
String topicName,
Schema<O> schema)
New output message using schema for serializing to the topic in the cluster
|
<O> CompletableFuture<Void> |
publish(String topicName,
O object)
Deprecated.
in favor of using
newOutputMessage(String, Schema) |
<O> CompletableFuture<Void> |
publish(String topicName,
O object,
String schemaOrSerdeClassName)
Deprecated.
in favor of using
newOutputMessage(String, Schema) |
void |
putState(String key,
ByteBuffer value)
Update the state value for the key.
|
CompletableFuture<Void> |
putStateAsync(String key,
ByteBuffer value)
Update the state value for the key, but don't wait for the operation to be completed
|
void |
recordMetric(String metricName,
double value)
Record a user defined metric.
|
Record<?> getCurrentRecord()
Collection<String> getInputTopics()
String getOutputTopic()
String getOutputSchemaType()
String getTenant()
String getNamespace()
String getFunctionName()
String getFunctionId()
int getInstanceId()
int getNumInstances()
String getFunctionVersion()
org.slf4j.Logger getLogger()
<S extends StateStore> S getStateStore(String name)
S - the type of interface of the store to returnname - the state store nameClassCastException - if the return type isn't a type
or interface of the actual returned store.<S extends StateStore> S getStateStore(String tenant, String ns, String name)
S - the type of interface of the store to returntenant - the state tenant namens - the state namespace namename - the state store nameClassCastException - if the return type isn't a type
or interface of the actual returned store.void incrCounter(String key, long amount)
key - The name of the keyamount - The amount to be incrementedCompletableFuture<Void> incrCounterAsync(String key, long amount)
key - The name of the keyamount - The amount to be incrementedlong getCounter(String key)
key - name of the keyCompletableFuture<Long> getCounterAsync(String key)
key - name of the keyvoid putState(String key, ByteBuffer value)
key - name of the keyvalue - state value of the keyCompletableFuture<Void> putStateAsync(String key, ByteBuffer value)
key - name of the keyvalue - state value of the keyvoid deleteState(String key)
key - name of the keyCompletableFuture<Void> deleteStateAsync(String key)
key - name of the keyByteBuffer getState(String key)
key - name of the keyCompletableFuture<ByteBuffer> getStateAsync(String key)
key - name of the keyMap<String,Object> getUserConfigMap()
Optional<Object> getUserConfigValue(String key)
key - The keyObject getUserConfigValueOrDefault(String key, Object defaultValue)
key - defaultValue - String getSecret(String secretName)
secretName - The name of the secretPulsarAdmin getPulsarAdmin()
PulsarAdmin getPulsarAdmin(String clusterName)
clusterName - The name of the cluster name for pulsar admin clientvoid recordMetric(String metricName, double value)
metricName - The name of the metricvalue - The value of the metric<O> CompletableFuture<Void> publish(String topicName, O object, String schemaOrSerdeClassName)
newOutputMessage(String, Schema)topicName - The name of the topic for publishingobject - The object that needs to be publishedschemaOrSerdeClassName - Either a builtin schema type (eg: "avro", "json", "protobuf") or the class name
of the custom schema class<O> CompletableFuture<Void> publish(String topicName, O object)
newOutputMessage(String, Schema)topicName - The name of the topic for publishingobject - The object that needs to be published<O> TypedMessageBuilder<O> newOutputMessage(String topicName, Schema<O> schema) throws PulsarClientException
O - topicName - The name of the topic for output messageschema - provide a way to convert between serialized data and domain objectsPulsarClientException<O> TypedMessageBuilder<O> newOutputMessage(String clusterName, String topicName, Schema<O> schema) throws PulsarClientException
O - clusterName - the name of the cluster for topictopicName - The name of the topic for output messageschema - provide a way to convert between serialized data and domain objectsPulsarClientException<O> ConsumerBuilder<O> newConsumerBuilder(Schema<O> schema) throws PulsarClientException
O - schema - provide a way to convert between serialized data and domain objectsPulsarClientExceptionCopyright © 2017–2021 Apache Software Foundation. All rights reserved.