Dispenser.MonitoredBuffer (dispenser v0.1.0) View Source
A MonitoredBuffer contains most of the logic required to implement a GenServer that wraps a Buffer.
MonitoredBuffer combines a Buffer to track events and a SubscriptionManager to track subscribers.
Link to this section Summary
Types
Various statistics exposed by the MonitoredBuffer for use by debugging and metrics.
The opaque internal state of the MonitoredBuffer.
Functions
Add events to the MonitoredBuffer.
Ask for events from the Buffer.
Given the current events and demands, returns the events to send to each subscriber.
Stop monitoring and remove all demand from the given subscriber.
Handle the down signal from a monitored subscriber.
Create a new MonitoredBuffer that wraps the given Buffer.
Get the number of events in the MonitoredBuffer.
Get various statistics about the MonitoredBuffer for use when debugging and generating metrics.
Link to this section Types
Specs
stats() :: %{
buffered: non_neg_integer(),
subscribed: non_neg_integer(),
demand: non_neg_integer()
}
Various statistics exposed by the MonitoredBuffer for use by debugging and metrics.
See stats/1
Specs
t(event)
The opaque internal state of the MonitoredBuffer.
Link to this section Functions
Specs
append(t(event), [event]) :: {t(event), dropped :: non_neg_integer()} when event: any()
Add events to the MonitoredBuffer.
If the MonitoredBuffer reaches its capacity, events will be dropped.
Specs
ask(t(event), subscriber :: pid(), demand :: non_neg_integer()) :: t(event) when event: any()
Ask for events from the Buffer.
These demands are met by calls to assign_events/1
Specs
Given the current events and demands, returns the events to send to each subscriber.
Specs
delete(t(event), subscriber :: pid()) :: {:ok, t(event)} | {:error, :not_subscribed} when event: any()
Stop monitoring and remove all demand from the given subscriber.
Specs
down(t(event), subscriber :: pid(), reference()) :: {:ok, t(event)} | {:error, :wrong_ref} | {:error, :not_subscribed} when event: any()
Handle the down signal from a monitored subscriber.
Specs
new(Dispenser.Buffer.t(event, pid())) :: t(event) when event: any()
Create a new MonitoredBuffer that wraps the given Buffer.
Specs
size(t(event)) :: non_neg_integer() when event: any()
Get the number of events in the MonitoredBuffer.
Specs
Get various statistics about the MonitoredBuffer for use when debugging and generating metrics.