franz/topic_subscriber

Types

Return type for topic subscriber acknowledgements.

pub type Ack

A builder for creating and configuring a Kafka topic subscriber.

pub opaque type Builder(callback_init_state)

Values

pub fn ack(cb_state: cb_state) -> Ack

Acknowledges the processing of a message. Use this in your callback to confirm message receipt.

pub fn new(
  client client: franz.Client,
  topic topic: String,
  partitions partitions: partitions.Partitions,
  message_type message_type: message_type.MessageType,
  callback callback: fn(
    Int,
    franz.KafkaMessage,
    callback_init_state,
  ) -> Ack,
  init_callback_state init_callback_state: callback_init_state,
) -> Builder(callback_init_state)

Creates a new topic subscriber builder. The callback will be called for each message received from the topic partitions.

pub fn start(
  builder: Builder(callback_init_state),
) -> Result(process.Pid, franz.FranzError)

Starts a new topic subscriber with the configured settings. Returns the process ID of the subscriber on success.

pub fn with_commited_offset(
  builder: Builder(callback_init_state),
  partition partition: Int,
  offset offset: Int,
) -> Builder(callback_init_state)

Adds a committed offset to the topic subscriber builder. CommittedOffsets are the offsets for the messages that have been successfully processed (acknowledged), not the begin-offset to start fetching from.

pub fn with_config(
  builder: Builder(callback_init_state),
  consumer_config: consumer_config.ConsumerConfig,
) -> Builder(callback_init_state)

Adds a consumer configuration option to the topic subscriber builder. Multiple configurations can be chained together.

Search Document