feat(function): expose producer configuration on pulsar_function - #223
Merged
freeznet merged 2 commits intoAug 26, 2026
Merged
Conversation
This was referenced Aug 21, 2026
pulsar_source exposes its producer configuration as top-level attributes - max_pending_messages, max_pending_messages_across_partitions, use_thread_local_producers, batch_builder and compression_type. pulsar_function exposes none of it: utils.FunctionConfig carries the same ProducerConfig field, but marshalFunctionConfig never populated it, so it was always sent nil and a function's output producer was stuck on defaults. Add the same five attributes, using the names pulsar_source already uses so the two resources read the same way, and populate FunctionConfig's ProducerConfig from them. The producer config is omitted entirely when none of the attributes are set, so requests for functions that do not configure a producer are unchanged. This is the part of streamnative#220 that needs nothing upstream. The batching_config block is deliberately not included: PIP-401's batchingConfig is absent from utils.ProducerConfig in the pinned admin client - tracked in apache/pulsar-client-go#1528, with a fix open at apache/pulsar-client-go#1530 - and it exists only on Pulsar 4.1.0 and later, whereas the acceptance tests here run against 4.0.3. Master Issue: streamnative#220 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
freeznet
force-pushed
the
feat/function-producer-config
branch
from
August 26, 2026 08:53
3059867 to
3447080
Compare
Member
|
Rebased this branch onto current Changes:
Validation:
|
freeznet
approved these changes
Aug 26, 2026
maxsxu
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Master Issue: #220
Covers the part of #220 that has no upstream dependency. The
batching_configblock is deliberately out of scope — see below.Motivation
pulsar_sourceexposes its producer configuration as top-level attributes (resource_pulsar_source.go):max_pending_messages,max_pending_messages_across_partitions,use_thread_local_producers,batch_builder,compression_type.pulsar_functionexposes none of it.utils.FunctionConfigcarries the sameProducerConfig *ProducerConfigfield, butmarshalFunctionConfignever populated it, so it was always sent nil — a function's output producer could not be configured from Terraform at all, including its compression.Modifications
pulsar_function, reusingpulsar_source's names and description strings verbatim so the two resources read the same way.FunctionConfig.ProducerConfiginmarshalFunctionConfigvia a newmarshalFunctionProducerConfig, following the shapepulsar_sourceuses.unmarshalFunctionProducerConfig, surfacing each field only when the server returned something for it so a function that configures none of them does not gain a diff.docs/resources/function.md.marshalFunctionProducerConfigreturns nil when none of the attributes are set, so the request for a function that does not configure a producer is byte-identical to before.Out of scope, deliberately:
batching_config. Two independent reasons, either of which alone would block it:batchingConfigis absent fromutils.ProducerConfigin the pinned admin client, so there is nothing to serialize into. Tracked as pulsaradmin: ProducerConfig cannot express PIP-401 batchingConfig apache/pulsar-client-go#1528, with a fix open at feat(pulsaradmin): add PIP-401 batchingConfig to ProducerConfig apache/pulsar-client-go#1530.BatchingConfig.javadoes not exist on the v4.0.x tags. The acceptance tests here run against 4.0.3 (hack/pulsarimage/Dockerfile), so it could not be acceptance-tested on the current baseline without bumping the image or scoping those tests around it. Worth deciding separately.Worth knowing about runtime support.
compression_typeandbatch_builderare honoured by the Python function runtime;max_pending_messagesis not (the Python runtime reads onlycompressionTypeandbatchBuilderfrom theProducerSpec). The provider should still send all of them — the broker stores them and the Java runtime applies them — but a Python function author should not expectmax_pending_messagesto take effect today. The Go runtime has the same gap, tracked at apache/pulsar#26391.Verifying this change
This change added tests and can be verified as follows:
pulsar/testdata/function/main.tfsets all five attributes, andTestFunctionasserts each one round-trips through a real broker.functionConfig.ProducerConfig = ...assignment and re-running fails five assertions.make testandgolangci-lintare clean;go generate ./...reproduces the committed docs.Documentation
Check the box below.
Need to update docs?
doc-requiredno-need-docdocdocs/resources/function.mdregenerated with the five new attributes.