kraken v0.1.1 Kraken.Limiter

Model of Limiter request subscribed to Client with partition :write or :read

This process is a ProducerConsumer for this GenStage pipeline.

Link to this section Summary

Functions

Check to reach limit

Gives events for the next stage to process when requested

Ask new events if needed

Starts an limiter manager linked to the current process

Link to this section Types

Link to this type options()
options() :: [max_demand: pos_integer() | nil, max_interval: timeout() | nil, min_interval: timeout() | nil, interval: timeout() | nil, clients: [{atom(), keyword()} | atom()]]
Link to this type state()
state() :: %Kraken.Limiter{call_counter: pos_integer(), interval: timeout(), max_demand: pos_integer(), max_interval: timeout(), producer: GenStage.from(), scheduled_at: pos_integer() | nil}

Link to this section Functions

Link to this function ask_and_schedule(state)

Check to reach limit.

If limit not reached ask again after :interval timeout, otherwise ask after :max_interval timeout.

Link to this function handle_demand(demand, state)

Gives events for the next stage to process when requested

Link to this function handle_events(events, from, state)
Link to this function handle_info(atom, state)

Ask new events if needed

Link to this function handle_subscribe(atom, arg2, from, state)
Link to this function start_link(options \\ [])
start_link(options()) :: GenServer.on_start()

Starts an limiter manager linked to the current process.

If the event manager is successfully created and initialized, the function returns {:ok, pid}, where pid is the PID of the server. If a process with the specified server name already exists, the function returns {:error, {:already_started, pid}} with the PID of that process.

Options

  • :name - used for name registration as described in the “Name registration” section of the module documentation
  • :interval - ask new events from producer after :interval milliseconds.
  • :max_demand - count of maximum requests per :maximum_interval
  • :max_interval - maximum time that allowed in :max_demand requests
  • :clients - list of clients with partition options. For example [Kraken.Client].