# `Klife.Behaviours.Partitioner`
[🔗](https://github.com/oliveigah/klife/blob/main/lib/klife/behaviours/partitioner.ex#L1)

Behaviour for defining a custom partitioner.

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

# `get_partition`

```elixir
@callback get_partition(
  record :: %Klife.Record{
    __arrival_ms: term(),
    __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(),
    timestamp: 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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
