Builtin middleware
Vumi ships with a small set of generically useful middleware:
Logs messages, events and failures as they enter or leave a transport.
-
class vumi.middleware.LoggingMiddleware(name, config, worker)
Middleware for logging messages published and consumed by
transports and applications.
Optional configuration:
Parameters: |
- log_level (string) – Log level from vumi.log to log inbound and outbound
messages and events at. Default is info.
- failure_log_level (string) – Log level from vumi.log to log failure messages at.
Default is error.
|
-
class vumi.middleware.TaggingMiddleware(name, config, worker)
Transport middleware for adding tag names to inbound messages and
for adding additional parameters to outbound messages based on
their tag.
Transports that wish to eventually have incoming messages
associated with an existing message batch by
vumi.application.MessageStore or via
vumi.middleware.StoringMiddleware need to ensure that
incoming messages are provided with a tag by this or some other
middleware.
Configuration options:
Parameters: |
- incoming (dict) –
- addr_pattern (string): Regular expression matching the
to_addr of incoming messages. Incoming messages with to_addr
values that don’t match the pattern are not modified.
- tagpool_template (string): Template for producing tag pool
from successful matches of addr_pattern. The string is
expanded using match.expand(tagpool_template).
- tagname_template (string): Template for producing tag name
from successful matches of addr_pattern. The string is
expanded using match.expand(tagname_template).
- outgoing (dict) –
- tagname_pattern (string): Regular expression matching
the tag name of outgoing messages. Outgoing messages with
tag names that don’t match the pattern are not
modified. Note: The tag pool the tag belongs to is not
examined.
- msg_template (dict): A dictionary of additional key-value
pairs to add to the outgoing message payloads whose tag
matches tag_pattern. Values which are strings are
expanded using match.expand(value). Values which are
dicts are recursed into. Values which are neither are left
as is.
|
-
class vumi.middleware.StoringMiddleware(name, config, worker)
Middleware for storing inbound and outbound messages and events.
Failures are not stored currently because these are typically
stored by :class:`vumi.transports.FailureWorker`s.
Messages are always stored. However, in order for messages to be
associated with a particular batch_id (
see vumi.application.MessageStore) a batch needs to be
created in the message store (typically by an application worker
that initiates sending outbound messages) and messages need to be
tagged with a tag associated with the batch (typically by an
application worker or middleware such as
vumi.middleware.TaggingMiddleware).
Configuration options:
Parameters: |
- store_prefix (string) – Prefix for message store keys in key-value store.
Default is ‘message_store’.
- redis (dict) – Redis configuration parameters.
|