Manages persistent storage of producer topic epochs across restarts.
This module provides an abstraction layer over ETS for storing and retrieving topic epochs for producers. The epochs are used to detect when a producer has been fenced by a newer producer with ExclusiveWithFencing access mode.
Each client maintains its own isolated epoch store, created when the client starts and cleaned up when the client stops.
Summary
Functions
Deletes the stored epoch for a producer.
Retrieves the stored epoch for a producer.
Initializes the epoch store for a client.
Stores the epoch for a producer.
Returns the ETS table name for a given client.
Functions
Deletes the stored epoch for a producer.
Parameters
client_name- The name of the clienttopic- The topic nameproducer_name- The producer nameaccess_mode- The producer access mode
Returns
:ok if successful, :error if the table doesn't exist
Examples
iex> ProducerEpochStore.delete(:default, "my-topic", "my-producer", :Exclusive)
:ok
Retrieves the stored epoch for a producer.
Parameters
client_name- The name of the clienttopic- The topic nameproducer_name- The producer nameaccess_mode- The producer access mode
Returns
{:ok, epoch}if an epoch is found:errorif no epoch is stored
Examples
iex> ProducerEpochStore.get(:default, "my-topic", "my-producer", :Exclusive)
{:ok, 5}
iex> ProducerEpochStore.get(:default, "new-topic", "new-producer", :Shared)
:error
@spec init(atom()) :: :ok
Initializes the epoch store for a client.
Creates the ETS table if it doesn't already exist. This is called when a Pulsar client starts.
Parameters
client_name- The name of the client
Returns
:ok
Stores the epoch for a producer.
Parameters
client_name- The name of the clienttopic- The topic nameproducer_name- The producer nameaccess_mode- The producer access modeepoch- The topic epoch to store
Returns
:ok if successful, :error if the table doesn't exist
Examples
iex> ProducerEpochStore.put(:default, "my-topic", "my-producer", :Exclusive, 5)
:ok
Returns the ETS table name for a given client.