A supervisor that manages individual producer groups for partitioned topics.
This module provides a logical abstraction over multiple producer groups,
allowing the start_producer API to return a single PID for partitioned topics
while maintaining the individual producer group architecture underneath.
The supervisor manages one producer group per partition, with the number of partitions provided by the caller.
Message Routing
Messages are routed to partitions based on the :partition_key option:
- With
:partition_key- Consistent hash routing via:erlang.phash2(partition_key, num_partitions) - Without
:partition_key- Random selection
Summary
Functions
Returns a specification to start this module under a supervisor.
Gets information about all child producer groups managed by this supervisor.
Gets all producer processes from all partition groups managed by this supervisor.
Sends a message through the partitioned producer.
Starts a partitioned producer supervisor.
Stops a partitioned producer supervisor and all its child producer groups.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Gets information about all child producer groups managed by this supervisor.
Returns a list of {partition_topic, group_pid} tuples.
Gets all producer processes from all partition groups managed by this supervisor.
Returns a flat list of producer process PIDs from all partitions.
Sends a message through the partitioned producer.
Routes the message to a partition based on the :partition_key option:
- With
:partition_key- Uses consistent hashing to route to a specific partition - Without
:partition_key- Uses random partition selection
Parameters
supervisor_pid- The partitioned producer supervisor PIDmessage- Binary message payloadopts- Optional parameters (same asPulsar.ProducerGroup.send_message/3)
Returns
{:ok, message_id} on success
{:error, reason} on failure
Starts a partitioned producer supervisor.
Parameters
name- Unique name for this partitioned producertopic- The base partitioned topic name (without partition suffix)partitions- Number of partitions for this topicopts- Additional options passed to individual producer groups
Returns
{:ok, pid} - The supervisor PID that manages all partition producer groups
{:error, reason} - Error if the supervisor failed to start
Stops a partitioned producer supervisor and all its child producer groups.