Skip to content

RandomRouter

Routes events randomly across a set of target entities.

Random router component for distributing requests across targets.

RandomRouter

RandomRouter(name: str, *, targets: list[Entity])

Bases: Entity

Routes requests randomly across a set of target entities.

A simple load balancer that distributes incoming events uniformly at random to one of the configured targets.

Parameters:

Name Type Description Default
name str

Entity name for identification.

required
targets list[Entity]

List of entities to route to.

required

handle_event

handle_event(event: Event) -> list[Event]

Route event to a randomly selected target.