elsa v0.8.0 Elsa.Producer

Defines functions to write messages to topics based on either a list of endpoints or a named client. All produce functions support the following options:

  • An existing named client process to handle the request can be specified by the keyword option name:.
  • If no partition is supplied, the first (zero) partition is chosen.
  • Value may be a single message or a list of messages.
  • If a list of messages is supplied as the value, the key is defaulted to an empty string binary.
  • If message value is a list, it is expected to be a list of key/value tuples.
  • Partition can be specified by the keyword option partition: and an integer corresponding to a specific partition, or the keyword option partitioner: and the atoms :md5 or :random. The atoms correspond to partitioner functions that will uniformely select a random partition from the total available topic partitions or assign an integer based on an md5 hash of the messages.

Link to this section Summary

Functions

Write the supplied message(s) to the desired topic/partition via an endpoint list and optional named client as a one-off operation. Following the completion of the operation, the producer is stopped. If no client is supplied, the default named client is chosen.

Write the supplied messages to the desired topic/partition via a named client specified as a keyword option (via the name: key). Messages may be a single message or a list of messages.

Link to this section Types

Link to this type

endpoints()
endpoints() :: [{hostname(), portnum()}]

Link to this type

hostname()
hostname() :: atom() | String.t()

Link to this type

portnum()
portnum() :: pos_integer()

Link to this type

topic()
topic() :: String.t()

Link to this section Functions

Link to this function

produce(endpoints, topic, messages, opts \\ [])
produce(
  endpoints(),
  topic(),
  {term(), term()} | term() | [{term(), term()}] | [term()],
  keyword()
) :: :ok

Write the supplied message(s) to the desired topic/partition via an endpoint list and optional named client as a one-off operation. Following the completion of the operation, the producer is stopped. If no client is supplied, the default named client is chosen.

Link to this function

produce_sync(topic, messages, opts \\ [])
produce_sync(
  topic(),
  {term(), term()} | term() | [{term(), term()}] | [term()],
  keyword()
) :: :ok

Write the supplied messages to the desired topic/partition via a named client specified as a keyword option (via the name: key). Messages may be a single message or a list of messages.