Skip to content

pulsar_function: producerConfig not exposed (compression_type, batch_builder, max_pending_messages), unlike pulsar_source #220

Description

@david-streamlio

Community Note

  • Please vote on this issue by adding a
    👍 reaction to the original
    issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra
    noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

pulsar_source exposes the source's producerConfig as top-level attributes - max_pending_messages, max_pending_messages_across_partitions, use_thread_local_producers, batch_builder, compression_type, and the producer crypto settings (resource_pulsar_source.go:55-65).

pulsar_function exposes none of it. utils.FunctionConfig carries the same ProducerConfig *ProducerConfig field (plus a top-level BatchBuilder), but marshalFunctionConfig never populates it, so it is always sent nil. A function's output producer is therefore stuck on broker/runtime defaults, and no amount of Terraform configuration can change its compression, batch builder, or pending-message queue sizing.

This is the same asymmetry that #217 covers on the consumer side, in the opposite direction: there the function was missing a block the sink already had; here it is missing a surface the source already has.

Suggested scope, matching the source's attribute names so the two resources read the same:

attribute utils.ProducerConfig field
max_pending_messages MaxPendingMessages
max_pending_messages_across_partitions MaxPendingMessagesAcrossPartitions
use_thread_local_producers UseThreadLocalProducers
batch_builder BatchBuilder
compression_type CompressionType

The producer crypto attributes could follow the source too, though they are less urgent and could reasonably be split out.

Batching is a follow-on, and is blocked upstream

The motivating case is publish latency. Pulsar Functions got a real producer-batching configuration path in PIP-401 (apache/pulsar#23860), which added BatchingConfig to ProducerConfig and wired it through to the ProducerBuilder for the Java runtime. Two open Pulsar issues track the runtimes that still ignore it:

Those are runtime bugs and do not require any change here - they are about honouring what already arrives in the FunctionDetails protobuf, and neither has been reviewed or merged. But note the ordering if the goal is "batching is tunable from IaC":

  1. utils.ProducerConfig in pulsar-client-go's pulsaradmin has no BatchingConfig field - it carries only MaxPendingMessages, MaxPendingMessagesAcrossPartitions, UseThreadLocalProducers, CryptoConfig, BatchBuilder and CompressionType. PIP-401's addition is not modelled there, so there is currently nothing for provider code to serialize into. That needs an upstream pulsar-client-go change first, now tracked as pulsaradmin: ProducerConfig cannot express PIP-401 batchingConfig apache/pulsar-client-go#1528.
  2. Then a batching_config block could be added here. At that point batching would be Terraform-configurable for Java functions, whose runtime has honoured batchingSpec since PIP-401.
  3. Python and Go functions would additionally need [fix][fn] Honour producerSpec batching configuration in the Python function runtime apache/pulsar#26392 / #26393 to merge before the setting took effect for them.

Everything in the table above is reachable today with no upstream dependency, which is why this issue is scoped to producerConfig generally rather than to batching alone.

Note that custom_runtime_options is not a workaround - it maps to customRuntimeOptions, which the worker passes to the runtime, not into producerSpec.

New or Affected Resource(s)

  • pulsar_function

Potential Terraform Configuration

resource "pulsar_function" "function-1" {
  provider = pulsar

  tenant    = "public"
  namespace = "default"
  name      = "function-1"

  jar       = "function://public/default/api-examples@v1"
  classname = "org.apache.pulsar.functions.api.examples.WordCountFunction"

  inputs = ["public/default/input1"]
  output = "public/default/test-out"

  # None of these are settable today.
  compression_type                       = "ZSTD"
  batch_builder                          = "KEY_BASED"
  max_pending_messages                   = 1000
  max_pending_messages_across_partitions = 50000
  use_thread_local_producers             = false
}

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions