Pulsar.PartitionedConsumer (Pulsar v2.8.13)

Copy Markdown View Source

A supervisor that manages individual consumer groups for partitioned topics.

This module provides a logical abstraction over multiple consumer groups, allowing the start_consumer API to return a single PID for partitioned topics while maintaining the individual consumer group architecture underneath.

The supervisor manages one consumer group per partition, with the number of partitions provided by the caller.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets all consumer processes from all partition groups managed by this supervisor.

Gets information about all child consumer groups managed by this supervisor.

Stops a partitioned consumer supervisor and all its child consumer groups.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_consumers(supervisor_pid)

Gets all consumer processes from all partition groups managed by this supervisor.

Returns a flat list of consumer process PIDs from all partitions.

get_partition_groups(supervisor_pid)

Gets information about all child consumer groups managed by this supervisor.

Returns a list of {partition_topic, group_pid} tuples.

start_link(name, topic, partitions, subscription_name, subscription_type, callback_module, opts \\ [])

Starts a partitioned consumer supervisor.

Parameters

  • name - Unique name for this partitioned consumer
  • topic - The base partitioned topic name (without partition suffix)
  • partitions - Number of partitions for this topic
  • subscription_name - Name of the subscription
  • subscription_type - Type of subscription (e.g., :Exclusive, :Shared, :Key_Shared)
  • callback_module - Module that implements Pulsar.Consumer.Callback behaviour
  • opts - Additional options passed to individual consumer groups

Returns

{:ok, pid} - The supervisor PID that manages all partition consumer groups {:error, reason} - Error if the supervisor failed to start

stop(supervisor_pid, reason \\ :normal, timeout \\ :infinity)

Stops a partitioned consumer supervisor and all its child consumer groups.