Queutils.BlockingQueueProducer (queutils v1.2.1) View Source
A GenStage producer that polls a Queutils.BlockingQueue at a fixed interval,
emitting any events on the queue.
Usage
Add it to your application supervisor's start/2 function, after the queue it pulls from, like this:
def start(_type, _args) do
children = [
...
{Queutils.BlockingQueue, name: MessageQueue, max_length: 10_000},
{Queutils.BlockingQueueProducer, name: MessageProducer},
...
]
opts = [strategy: :one_for_one, name: MyApplication.Supervisor]
Supervisor.start_link(children, opts)
endThe subscribe a consumer to it, like any other GenStage producer.
def init(_opts) do
{:consumer, :my_consumer_state, [subscribe_to: MessageProducer]}
endOptions
:name- the ID of the queue. This will be the first argument to thepush/2function. Default isBlockingQueueProducer.:max_length- The maximum number of messages that this process will store until it starts blocking. Default is 1,000.:dispatcher- TheGenStagedispatcher that this producer should use. Default isGenStage.DemandDispatcher.
Link to this section Summary
Functions
Start a blocking queue producer.
Link to this section Functions
Start a blocking queue producer.
Options
:name- the ID of the queue. This will be the first argument to thepush/2function. Default isBlockingQueueProducer.:max_length- The maximum number of messages that this process will store until it starts blocking. Default is 1,000.:dispatcher- TheGenStagedispatcher that this producer should use. Default isGenStage.DemandDispatcher.