The tulip.pkg.worker module exports the worker package.


  • tulip.pkg.mqueue
  • tulip.pkg.wmiddleware


  • idle_sleep: number = seconds to sleep when there are no messages to process. The first time no messages are available, it will sleep for idle_sleep, and double this sleep time on each loop without message, up to max_idle_sleep, until there are messages to process. Defaults to 1.
  • max_idle_sleep: number = maximum number of seconds to sleep when there are no messages to process. Defaults to 60.
  • queues: array of strings = name of queues to process, which can include name of cron jobs, which are essentially queues.
  • max_concurrency: number = maximum number of concurrent processing of messages. Defaults to 1 (for maximum control over TTL).
  • dequeue_batch: number = maximum number of messages to dequeue at once from a queue. Keep in mind that this is per queue that the worker will process, and the time-to-live of the message starts at the moment it is dequeued. Defaults to 1.
  • error_handler: function = if set, called when an error occurs in the worker look (e.g. when trying to dequeue a batch of messages). The first argument is the t table used to call the dequeue App:mqueue function, the second argument is the error itself and the third is the app instance. By default, errors are logged and the main loop sleeps as if there were no results to process. Errors that happen while processing a message are not handled with this, use a handler.wrecover middleware for that.

#API Extensions

Registering this package provides the following method and field extensions.


Takes control of the main loop of the App. Starts the worker process, calling the App instance with the Message instances for each message to process. See the mqueue package's documentation for the Message instance reference.


  • cq: userdata = the cqueue to use for the loop

Back to index

About this wiki

commit 3ebfbd288b8e5c95fdf8ce2027a0e94cfa1c8976
Author: Martin Angers <martin.n.angers@gmail.com>
Date:   2021-02-25T14:07:12-05:00

Update to reflect Request:validate_body
Clone this wiki
https://git.sr.ht/~mna/tulip-wiki (read-only)
git@git.sr.ht:~mna/tulip-wiki (read/write)