Klife.Behaviours.Partitioner behaviour (Klife v1.0.0)

View Source

Behaviour for defining a custom partitioner.

Modules must implement this behaviour in order to be used as partitioners on the Klife.Client producer API.

Summary

Callbacks

Defines the partition for a given record.

Callbacks

get_partition(record, max_partition)

@callback get_partition(
  record :: %Klife.Record{
    __batch_index: term(),
    __callback: term(),
    __estimated_size: term(),
    batch_attributes: term(),
    consumer_attempts: term(),
    error_code: term(),
    headers: term(),
    is_aborted: term(),
    key: term(),
    offset: term(),
    partition: term(),
    topic: term(),
    value: term()
  },
  max_partition :: integer()
) :: integer()

Defines the partition for a given record.

Receives the record and the highest known partition for the record's topic.

Must return an integer between 0 and max_partition. See Klife.Producer.DefaultPartitioner for an example.