Dispenser.Buffer (dispenser v0.1.0) View Source

A Dispenser.Buffer is a buffer that manages incoming events and demand for those events.

Link to this section Summary

Types

Various statistics exposed by the Buffer for use by debugging and metrics.

The opaque internal state of the Buffer.

Functions

Add events to the Buffer.

Ask for events from the Buffer.

Given the current events and demands, returns the events to send to each subscriber.

Remove all demand from the given subscriber.

Create a new Buffer with a maximum capacity.

Get the number of events in the Buffer.

Get various statistics about the Buffer for use when debugging and generating metrics.

Link to this section Types

Specs

stats() :: %{buffered: non_neg_integer(), demand: non_neg_integer()}

Various statistics exposed by the Buffer for use by debugging and metrics.

See stats/1

Link to this opaque

t(event, subscriber)

View Source (opaque)

Specs

t(event, subscriber)

The opaque internal state of the Buffer.

Link to this section Functions

Specs

append(t(event, subscriber), [event]) ::
  {t(event, subscriber), dropped :: non_neg_integer()}
when event: any(), subscriber: any()

Add events to the Buffer.

If the Buffer reaches its capacity, events will be dropped.

Link to this function

ask(state, subscriber, demand)

View Source

Specs

ask(t(event, subscriber), subscriber, non_neg_integer()) :: t(event, subscriber)
when event: any(), subscriber: any()

Ask for events from the Buffer.

These demands are met by calls to assign_events/1

Specs

assign_events(t(event, subscriber)) ::
  {t(event, subscriber), [{subscriber, [event]}]}
when event: any(), subscriber: any()

Given the current events and demands, returns the events to send to each subscriber.

Link to this function

delete(state, subscriber)

View Source

Specs

delete(t(event, subscriber), subscriber) :: t(event, subscriber)
when event: any(), subscriber: any()

Remove all demand from the given subscriber.

Link to this function

new(assignment_strategy, capacity, drop_strategy)

View Source

Specs

new(
  Dispenser.AssignmentStrategy.t(),
  pos_integer(),
  LimitedQueue.drop_strategy()
) :: t(event, subscriber)
when event: any(), subscriber: any()

Create a new Buffer with a maximum capacity.

Specs

size(t(event, subscriber)) :: non_neg_integer()
when event: any(), subscriber: any()

Get the number of events in the Buffer.

Specs

stats(t(event, subscriber)) :: stats() when event: any(), subscriber: any()

Get various statistics about the Buffer for use when debugging and generating metrics.