Middleware Classes¶
fastpubsub.BaseMiddleware
¶
Base class for middlewares.
Your middlewares should extend this class if you want to implement your own middleware.
Initializes the BaseMiddleware.
| PARAMETER | DESCRIPTION |
|---|---|
next_call
|
The next middleware or command in the chain.
TYPE:
|
Source code in fastpubsub/middlewares/base.py
on_message
async
¶
Handles a message.
When extending this methods, you should always call
await super().on_message(...) to continue the chain.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The message to handle.
TYPE:
|
Source code in fastpubsub/middlewares/base.py
on_publish
async
¶
Handles a publish event.
When extending this methods, you should always call
await super().on_publish(...) to continue the chain.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The message data.
TYPE:
|
ordering_key
|
The ordering key for the message.
TYPE:
|
attributes
|
A dictionary of message attributes. |
Source code in fastpubsub/middlewares/base.py
fastpubsub.Middleware
¶
Wrapper class for middlewares.
You should only use this class to create middlewares on class constructors. Its purpose is to only store the middleware. information for delayed initiatization.
Initializes the Middleware.
| PARAMETER | DESCRIPTION |
|---|---|
cls
|
The middleware class you want to initialize later.
TYPE:
|
args
|
The middleware class positional arguments.
TYPE:
|
kwargs
|
The middleware class keyword arguments.
TYPE:
|
Source code in fastpubsub/middlewares/base.py
fastpubsub.middlewares.GZipMiddleware
¶
Bases: BaseMiddleware
A middleware for compressing and decompressing messages using gzip.
Initializes the GZipMiddleware.
| PARAMETER | DESCRIPTION |
|---|---|
next_call
|
The next call in the chain to call.
TYPE:
|
compresslevel
|
The level of compression used on gzip.compress function on a ranges of 0 to 9.
TYPE:
|
mtime
|
The modification time. The modification time is set to the current time by default. |
Source code in fastpubsub/middlewares/gzip.py
on_message
async
¶
Decompresses a message.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The message to decompress.
TYPE:
|
Source code in fastpubsub/middlewares/gzip.py
on_publish
async
¶
Compresses a message.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The message data to compress.
TYPE:
|
ordering_key
|
The ordering key for the message.
TYPE:
|
attributes
|
A dictionary of message attributes. |