Packages

Elsa is a full-featured Kafka library written in Elixir and extending the :brod library with additional support from the :kafka_protocol Erlang libraries to provide capabilities not available in :brod.

Current section

Files

Jump to
elsa_kafka lib elsa partitioner random.ex
Raw

lib/elsa/partitioner/random.ex

defmodule Elsa.Partitioner.Random do
@moduledoc """
Randomly chooses a topic partition uniformly from the available
number of partitions.
"""
@behaviour Elsa.Partitioner
def partition(count, _key) do
:rand.uniform(count) - 1
end
end