DbQueue - do-/node-doix-db GitHub Wiki

DbQueue is a Queue descendant bound to a DbView. Its maxPending option is set to 1 forcibly.

This is the way to consider a SQL view with the addition of the ORDER BY clause as a sequence of objects similar to, say, parsed incoming HTTP requests and so, the data source for a sequence of Jobs.

DbQueue's .peek () implementation fetches the first record from the related .view respecting the .order. To prevent infinite looping, each Job created must modify its source database record to exclude it from the VIEW (e. g. UPDATE some status field or just DELETE completely), so calling .check () once will lead to executing a sequence of Jobs until the view gets empty or a fatal error occurs.

For most DbQueues, .check () should be called upon each INSERT into the underlying table. Some DBMS provide special ways to automate this task, but in general, it's up to the application to invoke the process having the incoming data provided.

On the other hand, in some cases, .check ()ing a DbQueue should be only by schedule. This is typical for processing expired data, when the SQL VIEW relies on the current timestamp.

Constructor

Never to be called directly. Instances of this class are inner to DbView ones.

Properties

See JobSource's Properties

Name Type Description Notes
view DbView The data source to peek in
order String The ORDER BY clause for selecting records to process first For FIFO semantics, oldest first

Methods

peek (job)

Finds the job's connection to the database corresponding to view.model.db and uses its .peek (queue) to fetch the next request parameters.