PHP Interface DominionEnterprises\Mongo\QueueInterface

Tied priorities are ordered by time. So you may use a single priority for normal queuing (default args exist for this purpose). Using a random priority achieves random get()
Datei anzeigen Open project: dominionenterprises/mongo-queue-php

Public Methods

Method Description
ack ( array $message ) : void Acknowledge a message was processed and remove from queue.
ackSend ( array $message, array $payload, integer $earliestGet, float $priority, boolean $newTimestamp = true ) : void Atomically acknowledge and send a message to the queue.
count ( array $query, boolean | null $running = null ) : integer Count queue messages.
ensureCountIndex ( array $fields, boolean $includeRunning ) : void Ensure an index for the count() method.
ensureGetIndex ( array $beforeSort = [], array $afterSort = [] ) : void Ensure an index for the get() method.
get ( array $query, integer $runningResetDuration, integer $waitDurationInMillis = 3000, integer $pollDurationInMillis = 200 ) : array | null Get a non running message from the queue.
requeue ( array $message, integer $earliestGet, float $priority, boolean $newTimestamp = true ) : void Requeue message to the queue. Same as ackSend() with the same message.
send ( array $payload, integer $earliestGet, float $priority ) : void Send a message to the queue.

Method Details

ack() public method

Acknowledge a message was processed and remove from queue.
public ack ( array $message ) : void
$message array message received from get()
return void

ackSend() public method

Atomically acknowledge and send a message to the queue.
public ackSend ( array $message, array $payload, integer $earliestGet, float $priority, boolean $newTimestamp = true ) : void
$message array the message to ack received from get()
$payload array the data to store in the message to send. Data is handled same way as \MongoDB\Collection::insertOne()
$earliestGet integer earliest unix timestamp the message can be retreived.
$priority float priority for order out of get(). 0 is higher priority than 1
$newTimestamp boolean true to give the payload a new timestamp or false to use given message timestamp
return void

count() public method

Count queue messages.
public count ( array $query, boolean | null $running = null ) : integer
$query array in same format as \MongoDB\Collection::find() where top level fields do not contain operators. Lower level fields can however. eg: valid {a: {$gt: 1}, "b.c": 3}, invalid {$and: [{...}, {...}]}
$running boolean | null query a running message or not or all
return integer the count

ensureCountIndex() public method

Ensure an index for the count() method.
public ensureCountIndex ( array $fields, boolean $includeRunning ) : void
$fields array fields in count() call to index in same format as \MongoDB\Collection::createIndex()
$includeRunning boolean whether to include the running field in the index
return void

ensureGetIndex() public method

Ensure an index for the get() method.
public ensureGetIndex ( array $beforeSort = [], array $afterSort = [] ) : void
$beforeSort array fields in get() call to index before the sort field.
$afterSort array fields in get() call to index after the sort field.
return void

get() public method

Get a non running message from the queue.
public get ( array $query, integer $runningResetDuration, integer $waitDurationInMillis = 3000, integer $pollDurationInMillis = 200 ) : array | null
$query array in same format as \MongoDB\Collection::find() where top level fields do not contain operators. Lower level fields can however. eg: valid {a: {$gt: 1}, "b.c": 3}, invalid {$and: [{...}, {...}]}
$runningResetDuration integer second duration the message can stay unacked before it resets and can be retreived again.
$waitDurationInMillis integer millisecond duration to wait for a message.
$pollDurationInMillis integer millisecond duration to wait between polls.
return array | null the message or null if one is not found

requeue() public method

Requeue message to the queue. Same as ackSend() with the same message.
public requeue ( array $message, integer $earliestGet, float $priority, boolean $newTimestamp = true ) : void
$message array message received from get().
$earliestGet integer earliest unix timestamp the message can be retreived.
$priority float priority for order out of get(). 0 is higher priority than 1
$newTimestamp boolean true to give the payload a new timestamp or false to use given message timestamp
return void

send() public method

Send a message to the queue.
public send ( array $payload, integer $earliestGet, float $priority ) : void
$payload array the data to store in the message. Data is handled same way as \MongoDB\Collection::insertOne()
$earliestGet integer earliest unix timestamp the message can be retreived.
$priority float priority for order out of get(). 0 is higher priority than 1
return void