Skip to main content
Version: 最新版

Pulsar Functions CLI and YAML configs

Pulsar admin CLI for Pulsar Functions

The Pulsar admin interface enables you to create and manage Pulsar Functions through CLI. For the latest and complete information, including commands, flags, and descriptions, refer to Pulsar admin CLI.

YAML configurations for Pulsar Functions

You can configure a function by using a predefined YAML file. The following table outlines the required fields and arguments.

Field NameTypeRelated Command ArgumentDescription
runtimeFlagsStringN/AAny flags that you want to pass to a runtime (for process & Kubernetes runtime only).
tenantString--tenantThe tenant of a function.
namespaceString--namespaceThe namespace of a function.
nameString--nameThe name of a function.
classNameString--classnameThe class name of a function.
inputsList<String>-i, --inputsThe input topics of a function. Multiple topics can be specified as a comma-separated list.
customSerdeInputsMap<String,String>--custom-serde-inputsThe mapping from input topics to SerDe class names.
topicsPatternString--topics-patternThe topic pattern to consume from a list of topics under a namespace.
Note: --input and --topic-pattern are mutually exclusive. For Java functions, you need to add the SerDe class name for a pattern in --custom-serde-inputs.
customSchemaInputsMap<String,String>--custom-schema-inputsThe mapping from input topics to schema properties.
customSchemaOutputsMap<String,String>--custom-schema-outputsThe mapping from output topics to schema properties.
inputSpecsMap<String,ConsumerConfig>--input-specsThe mapping from inputs to custom configurations.
outputString-o, --outputThe output topic of a function. If none is specified, no output is written.
producerConfigProducerConfig--producer-configThe custom configurations for producers.
outputSchemaTypeString-st, --schema-typeThe built-in schema type or custom schema class name used for message outputs.
outputSerdeClassNameString--output-serde-classnameThe SerDe class used for message outputs.
logTopicString--log-topicThe topic that the logs of a function are produced to.
processingGuaranteesString--processing-guaranteesThe processing guarantees (delivery semantics) applied to a function. Available values: ATLEAST_ONCE, ATMOST_ONCE, EFFECTIVELY_ONCE.
retainOrderingBoolean--retain-orderingWhether functions consume and process messages in order or not.
retainKeyOrderingBoolean--retain-key-orderingWhether functions consume and process messages in key order or not.
batchBuilderString--batch-builderUse producerConfig.batchBuilder instead.
Note: batchBuilder will be deprecated in code soon.
forwardSourceMessagePropertyBoolean--forward-source-message-propertyWhether the properties of input messages are forwarded to output topics or not during processing. When the value is set to false, the forwarding is disabled.
userConfigMap<String,Object>--user-configUser-defined config key/values.
secretsMap<String,Object>--secretsThe mapping from secretName to objects that encapsulate how the secret is fetched by the underlying secrets provider.
runtimeStringN/AThe runtime of a function. Available values: java,python, go.
autoAckBoolean--auto-ackWhether the framework acknowledges messages automatically or not.
maxMessageRetriesInt--max-message-retriesThe number of retries to process a message before giving up.
deadLetterTopicString--dead-letter-topicThe topic used for storing messages that are not processed successfully.
subNameString--subs-nameThe name of Pulsar source subscription used for input-topic consumers if required.
parallelismInt--parallelismThe parallelism factor of a function, that is, the number of function instances to run.
resources资源N/AN/A
fqfnString--fqfnThe Fully Qualified Function Name (FQFN) of a function.
windowConfigWindowConfigN/AN/A
timeoutMsLong--timeout-msThe message timeout (in milliseconds).
jarString--jarThe path of the JAR file for a function (written in Java). It also supports URL paths that workers can download the package from, including HTTP, HTTPS, file (file protocol assuming that file already exists on worker host), and function (package URL from packages management service).
pyString--pyThe path of the main Python/Python wheel file for a function (written in Python). It also supports URL paths that workers can download the package from, including HTTP, HTTPS, file (file protocol assuming that file already exists on worker host), and function (package URL from packages management service).
goString--goPath to the main Go executable binary for the function (written in Go). It also supports URL paths that workers can download the package from, including HTTP, HTTPS, file (file protocol assuming that file already exists on worker host), and function (package URL from packages management service).
cleanupSubscriptionBooleanN/AWhether the subscriptions that a function creates or uses should be deleted or not when the function is deleted.
customRuntimeOptionsString--custom-runtime-optionsA string that encodes options to customize the runtime.
maxPendingAsyncRequestsInt--max-message-retriesThe max number of pending async requests per instance to avoid a large number of concurrent requests.
exposePulsarAdminClientEnabledBooleanN/AWhether the Pulsar admin client is exposed to function context or not. By default, it is disabled.
subscriptionPositionString--subs-positionThe position of Pulsar source subscription used for consuming messages from a specified location. The default value is Latest.
ConsumerConfig

The following table outlines the nested fields and related arguments under the inputSpecs field.

Field NameTypeRelated Command ArgumentDescription
schemaTypeStringN/AN/A
serdeClassNameStringN/AN/A
isRegexPatternBooleanN/AN/A
schemaPropertiesMap<String,String>N/AN/A
consumerPropertiesMap<String,String>N/AN/A
receiverQueueSizeIntN/AN/A
cryptoConfigCryptoConfigN/ARefer to code.
poolMessagesBooleanN/AN/A
ProducerConfig

The following table outlines the nested fields and related arguments under the producerConfig field.

Field NameTypeRelated Command ArgumentDescription
maxPendingMessagesIntN/AThe max size of a queue that holds messages pending to receive an acknowledgment from a broker.
maxPendingMessagesAcrossPartitionsIntN/AThe number of maxPendingMessages across all partitions.
useThreadLocalProducersBooleanN/AN/A
cryptoConfigCryptoConfigN/ARefer to code.
batchBuilderString--batch-builderThe type of batch construction method. Available values: DEFAULT and KEY_BASED. The default value is DEFAULT.
资源

The following table outlines the nested fields and related arguments under the resources field.

Field NameTypeRelated Command ArgumentDescription
cpudouble--cpuThe CPU in cores that need to be allocated per function instance (for Kubernetes runtime only).
ramLong--ramThe RAM in bytes that need to be allocated per function instance (for process/Kubernetes runtime only).
diskLong--diskThe disk in bytes that need to be allocated per function instance (for Kubernetes runtime only).
WindowConfig

The following table outlines the nested fields and related arguments under the windowConfig field.

Field NameTypeRelated Command ArgumentDescription
windowLengthCountInt--window-length-countThe number of messages per window.
windowLengthDurationMsLong--window-length-duration-msThe time duration (in milliseconds) per window.
slidingIntervalCountInt--sliding-interval-countThe number of messages after which a window slides.
slidingIntervalDurationMsLong--sliding-interval-duration-msThe time duration after which a window slides.
lateDataTopicStringN/AN/A
maxLagMsLongN/AN/A
watermarkEmitIntervalMsLongN/AN/A
timestampExtractorClassNameStringN/AN/A
actualWindowFunctionClassNameStringN/AN/A
CryptoConfig

The following table outlines the nested fields and related arguments under the cryptoConfig field.

Field NameTypeRelated Command ArgumentDescription
cryptoKeyReaderClassNameStringN/ARefer to code.
cryptoKeyReaderConfigMap<String, Object>N/AN/A
encryptionKeysString[]N/AN/A
producerCryptoFailureActionProducerCryptoFailureActionN/AN/A
consumerCryptoFailureActionConsumerCryptoFailureActionN/AN/A

Example

The following example shows how to configure a function using YAML or JSON.

tenant: "public"
namespace: "default"
name: "config-file-function"
inputs:
- "persistent://public/default/config-file-function-input-1"
- "persistent://public/default/config-file-function-input-2"
output: "persistent://public/default/config-file-function-output"
jar: "function.jar"
parallelism: 1
resources:
cpu: 8
ram: 8589934592
autoAck: true
userConfig:
foo: "bar"