Skip to content

New Feature Idea: Add EventResult.priority to allow filtering/re-ordering handlers at dispatch time #6

@pirate

Description

@pirate
  1. Explicitly document handler priority order is the same as registration order by default
  2. Add an attr to BaseEvent called event_handler_order to allow overriding the execution order of handlers on a per-event basis
class BaseEvent(BaseModel):
    ...

    event_handler_order: tuple[HandlerIdStr, ...] | None = None

AND / OR

class EventResult(BaseModel):
    ...

    order: int = 0   # any int order, lower numbers go first, higher go later
	# e.g. for a special handler that should run before all other handlers, set to -100
	# for a cleanup/teardown handler that should run after all others, set to 100, etc.

when parallel_handlers = False currently handlers are executed in FIFO order based on handler registration order. when set, event_handler_order should allow overriding which handlers execute and in what order on a per-event basis.
if set, it should warn if parallel_handlers is True because it will be ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions