batch_stage v0.1.0 BatchStage View Source

A stage that will try to batch incoming events into bigger portions so events are not sent one-by-one.

Link to this section Summary

Functions

Appends a number of events to the internal batch asynchronously

Appends a single event to the internal batch

Starts the stage. args is a keyword list with these options

Link to this section Functions

Appends a number of events to the internal batch asynchronously.

Link to this function append_one(stage, event) View Source

Appends a single event to the internal batch.

If possible, you should use append/2 instead of append_one/2.

Link to this function start_link(args, options) View Source

Starts the stage. args is a keyword list with these options:

  • :timeout - If an event comes in and the internal batch is empty, this stage will wait this number of milliseconds before sending it. 1_000 by default.
  • :stage_type - The stage type init/1 will return. Can be :producer or :consumer_producer. :producer by default, or :consumer_producer if :subscribe_to is not empty.
  • :subscribe_to - List of subscriptions init/1 will return. [] by default.
  • :demand - The maximum amount of events to send in one batch.

The options will be passed to the options argument of GenStage.start_link/3.