~mna/tulip

The tulip.pkg.wmiddleware module exports the wmiddleware package. It enables app-level worker middleware (as opposed to queue-specific worker middleware) in the order specified in the configuration. This means that messages will go through those middleware handlers in that order.

#Configuration

  • array of string|function = the order of the middleware to apply to worker messages.

#API Extensions

Registering this package provides the following method and field extensions.

#App(msg, nxt)

Sets up the __call metamethod on the App's metatable so that it can be used as initial middleware.

Args:

  • msg: table = the worker Message instance
  • nxt: function|nil = the function that calls the next middleware
#f = App:lookup_wmiddleware(name)

Returns the wmiddleware registered for that name, or nil if none.

Args:

  • name: string = the name for the registered wmiddleware

Returns:

  • f: function = the registered wmiddleware
#App:register_wmiddleware(name, mw)

Registers the wmiddleware mw for name. If there is already a registered wmiddleware for name, throws an error.

Args:

  • name: string = the name of the wmiddleware
  • mw: function = middleware function (or callable table)
#App:resolve_wmiddleware(mws)

Resolves the wmiddleware identified by a string in the array mws to their actual function (or callable table).

Args:

  • mws: array of string|function = the defined wmiddleware
#App.wmiddleware: array of string|function

The list of wmiddleware to apply to worker messages. When the App is called as initial middleware, it triggers that chain of middleware next, in sequence.

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)