You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/middleware/building_your_own_middleware.rst
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@ A middleware class provides three handler functions, one for processing each of
5
5
6
6
Although transport and application middleware potentially both provide the same sets of handlers, the two make use of them in slightly different ways. Inbound messages and events are published by transports but consumed by applications while outbound messages are opposite.
7
7
8
-
A middleware is required to subclass BaseMiddleware. This is a convenient definition of and set of common functionality for middleware classes. However you should not override :py:data:`__init__()`. Custom setup should be done in
9
-
:py:data:`setup()` instead (if required). The config class can be overidden by replacing the :py:data:`config` variable.
10
-
You should also overwrite :py:data:`handle_{type}(self, msg, connection)` in most cases while using :py:data:`{type}_enabled(self, connector_name)` from the base class
8
+
A middleware is required to subclass BaseMiddleware. This is a convenient definition of and set of common functionality for middleware classes. However you should not override :py:meth:`__init__()`. Custom setup should be done in
9
+
:py:meth:`setup()` instead (if required). The config class can be overidden by replacing the :py:meth:`config` variable.
10
+
You should also overwrite :py:meth:`handle_{type}(self, msg, connection)` in most cases while using :py:meth:`{type}_enabled(self, connector_name)` from the base class
11
11
12
12
13
13
See logging and unidecoder examples
@@ -18,10 +18,10 @@ How your middleware is used inside Vumi:
18
18
While writing complex middleware, it may help to understand how a middleware class is used by Vumi transports and applications.
19
19
20
20
When a transport or application is started a list of middleware to load is read from the configuration.
21
-
An instance of each piece of middleware is created and then ``setup()`` is called on each middleware object in
22
-
order within the ``setup()`` of the worker
21
+
An instance of each piece of middleware is created and then :py:meth:`setup()` is called on each middleware object in
22
+
order within the :py:meth:`setup()` of the worker
23
23
24
-
``middleware_{type}_handler function`` (e.g., middleware_outbound_handler) of BaseWorker of each message type. This function will:
25
-
Filter the middleware list based on connector_name and the middleware's ``{type}_enabled`` method.
26
-
Create a decorated handler function that sequentially applies each enabled middleware's ``handle_{type}`` method to the message.
24
+
:py:meth:`middleware_{type}_handler` function (e.g., middleware_outbound_handler) of BaseWorker of each message type. This function will:
25
+
Filter the middleware list based on connector_name and the middleware's :py:meth:`{type}_enabled` method.
26
+
Create a decorated handler function that sequentially applies each enabled middleware's :py:meth:`handle_{type}` method to the message.
27
27
Return the decorated handler. This decorated handler is then used in setting up the connection
0 commit comments