silverback.middlewares

The silverback.middlewares module contains middleware intended to improve the usability of silverback as a whole, and add integrations for the silverback platform as well.

class silverback.middlewares.SilverbackMiddleware(*args, **kwargs)

Bases: TaskiqMiddleware, ManagerAccessMixin

post_execute(message: TaskiqMessage, result: TaskiqResult)

This hook executes after task is complete.

This is a worker-side hook. It’s called in worker process.

Parameters:
  • message – incoming message.

  • result – result of execution for current task.

pre_execute(message: TaskiqMessage) TaskiqMessage

This hook is called before executing task.

This is a worker-side hook, which means it executes in the worker process.

Parameters:

message – incoming parsed taskiq message.

Returns:

modified message.

pre_send(message: TaskiqMessage) TaskiqMessage

Hook that executes before sending the task to worker.

This is a client-side hook, that executes right before the message is sent to broker.

Parameters:

message – message to send.

Returns:

modified message.