Skip to content

feat: let middlewares declare task-only labels - #725

Open
summer000 wants to merge 1 commit into
taskiq-python:masterfrom
summer000:feature/task-local-labels
Open

summer000 wants to merge 1 commit into
taskiq-python:masterfrom
summer000:feature/task-local-labels

Conversation

@summer000

Copy link
Copy Markdown

Some middlewares need a task-level parameter that isn't serialized and is read from the registered task instead of from the message, the way types_of_exceptions works for the retry middlewares.

Currently this only works for types_of_exceptions, because the kicker skips it by name when building a message. This means core code knows about parameters used by a specific middleware, and custom middlewares have no way to get the same behavior for their own labels.

This PR lets a middleware declare such labels itself via task_only_labels. The kicker skips them when building a message, and the retry middlewares declare types_of_exceptions this way instead of the hardcoded check.

The kicker hardcoded the `types_of_exceptions` label name to keep it
off the wire. That leaks middleware-specific knowledge into core code.

Add a `task_only_labels` declaration to TaskiqMiddleware. Labels named
there should be read only from the registered task and are skipped when
kicker builds a message, so they are not serialized.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant