brodex v0.0.1 Brodex View Source

Brodex is a thin wrapper of :brod.

Configuration

See brod README for details.

config :brod,
  clients: [
    my_client: [
      endpoints: [{'127.0.0.1', 9092}],
      reconnect_cool_down_seconds: 10
    ]
  ]

If you use mix release

# config/releases.exs
config :brod,
  clients: [
    my_client: [
      endpoints: Brodex.parse_endpoints(System.fetch_env!("KAFKA_ENDPOINTS)),
      reconnect_cool_down_seconds: 10
    ]
  ]

Link to this section Summary

Link to this section Types

Link to this type

batch_input()

View Source
batch_input() :: [msg_input()]

:kpro.batch_input

Link to this type

bootstrap()

View Source
bootstrap() :: [endpoint()] | {[endpoint()], client_config()}

:brod.bootstrap

Link to this type

call_ref()

View Source
call_ref() ::
  {:brod_call_ref, caller :: :undefined | pid(), callee :: :undefined | pid(),
   ref :: :undefined | reference()}

:brod.call_ref

:brod.client

Link to this type

client_config()

View Source
client_config() :: :proplists.proplist()

:brod.client_config

Link to this type

client_id()

View Source
client_id() :: atom()

:brod.client_id

Link to this type

connection()

View Source
connection() :: pid()

:brod.connection

Link to this type

consumer_config()

View Source
consumer_config() :: :proplists.proplist()

:brod.consumer_config

:brod.endpoint

Link to this type

fetch_opt()

View Source
fetch_opt() ::
  {:max_wait_time, non_neg_integer()}
  | {:min_bytes, non_neg_integer()}
  | {:max_bytes, non_neg_integer()}
Link to this type

group_config()

View Source
group_config() :: :proplists.proplist()

:brod.group_config

Link to this type

group_id()

View Source
group_id() :: binary()

:brod.group_id

Link to this type

headers()

View Source
headers() :: [{binary(), binary()}]

:kpro.headers

Link to this type

int32()

View Source
int32() :: -2_147_483_648..2_147_483_647

:kpro.int32

Link to this type

int64()

View Source
int64() :: -9_223_372_036_854_775_808..9_223_372_036_854_775_807

:kpro.int64

Link to this type

key()

View Source
key() :: :undefined | binary()

:brod.key

Link to this type

msg_input()

View Source
msg_input() :: %{headers: headers(), ts: msg_ts(), key: key(), value: value()}

:kpro.msg_input

:brod.msg_ts

:brod.offset

Link to this type

partition()

View Source
partition() :: int32()

:brod.partition

Link to this type

partitioner()

View Source
partitioner() ::
  (topic(), pos_integer(), key(), value() -> {:ok, partition()})
  | :random
  | :hash

:brod.partitioner

:brod.topic

Link to this type

value()

View Source
value() ::
  :undefined
  | iodata()
  | {msg_ts(), binary()}
  | [{key(), value()}]
  | [{msg_ts(), key(), value()}]
  | msg_input()
  | batch_input()

:brod.value

Link to this section Functions

Link to this function

fetch(conn_spec, topic, partition, offset, options \\ [])

View Source
fetch(
  connection() | client_id() | bootstrap(),
  topic(),
  partition(),
  offset(),
  [fetch_opt()]
) :: {:ok, {offset(), [Brodex.Message.record()]}} | {:error, term()}

Wrapper of :brod.fetch/5

Link to this function

get_metadata(endpoints, topic, connect_config \\ [])

View Source
get_metadata([endpoint()], :all | [topic()], :brod.conn_config()) ::
  {:ok, :kpro.struct()} | {:error, term()}

Wrapper of :brod.get_metadata/3

Link to this function

get_partitions_count(client, topic)

View Source
get_partitions_count(client(), topic()) ::
  {:ok, pos_integer()} | {:error, term()}

Wrapper of :brod.get_partitions_count/2

Link to this function

list_all_consumer_groups(endpoints, connect_config \\ [])

View Source
list_all_consumer_groups([endpoint()], :brod.conn_config()) :: [
  {endpoint(), [:brod.cg()] | {:error, term()}}
]

Wrapper of :brod.list_all_groups/2

Link to this function

list_consumer_groups(endpoint, connect_config \\ [])

View Source
list_consumer_groups(endpoint(), :brod.conn_config()) ::
  {:ok, [:brod.cg()]} | {:error, term()}

Wrapper of :brod.list_groups/2

Link to this function

parse_endpoints(endpoints)

View Source
parse_endpoints(String.t()) :: [endpoint()]

Parse endpoints.

Examples

iex> Brodex.parse_endpoints("kafka1:9000,kafka:9001")
[{'kafka1', 9000}, {'kafka', 9001}]
Link to this function

produce_async(client, topic, input, partition_spec \\ :hash)

View Source
produce_async(
  client(),
  topic(),
  input :: {key(), value()} | value(),
  partition() | partitioner()
) :: {:ok, call_ref()} | {:error, term()}

Wrapper of :brod.produce/5.

Link to this function

produce_sync(client, topic, input, partition_spec \\ :hash)

View Source
produce_sync(
  client(),
  topic(),
  input :: {key(), value()} | value(),
  partition() | partitioner()
) :: :ok | {:error, term()}

Wrapper of :brod.produce_sync/5.

Link to this function

start_client(endpoints, client_id, options \\ [])

View Source
start_client([endpoint()], client_id(), :brod.client_config()) ::
  :ok | {:error, term()}

Wrapper of :brod.start_client/3.

Link to this function

stop_client(client)

View Source
stop_client(client()) :: :ok

Wrapper of :brod.stop_client/1.