Pulsar.PartitionDiscovery (Pulsar v2.10.1)

Copy Markdown View Source

Periodically polls a partitioned topic's metadata and grows a partitioned consumer/producer supervisor when new partitions are added to the topic.

Pulsar only ever increases a topic's partition count, so discovery is grow-only: any partition indices that are missing from the supervisor are added, existing partitions are left untouched, and a reported count that is not larger than the current one (including a transient lookup error) is ignored.

This runs as a :worker child of the Pulsar.PartitionedConsumer / Pulsar.PartitionedProducer supervisor it manages, and adds new partition children to that same supervisor via Supervisor.start_child/2.

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns the child spec(s) for a discovery poller attached to supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

child_specs(supervisor, opts)

@spec child_specs(
  pid(),
  keyword()
) :: [Supervisor.child_spec()]

Returns the child spec(s) for a discovery poller attached to supervisor.

Returns a single-element list when discovery is enabled, or an empty list when it is disabled, so the supervisor never starts a poller process it doesn't need.

opts:

  • :topic - base partitioned topic name (required)
  • :client - client name (required)
  • :build_child_spec - 1-arity fun mapping a partition index to the child spec for that partition's consumer/producer group (required)
  • :interval_ms - poll interval in milliseconds (required), or false to disable discovery.

start_link(supervisor, opts)