Router

class Router(routes: Map<KClass<out Event>, List<Agent>> = emptyMap())

Maps event types to the agents that should receive them.

The router is populated up-front when wiring an agent system and is effectively read-only from then on — it is not thread-safe across concurrent addRoute calls. Looking up agents during dispatch is concurrency-safe because the underlying map is no longer mutated.

Constructors

Link copied to clipboard
constructor(routes: Map<KClass<out Event>, List<Agent>> = emptyMap())

Functions

Link copied to clipboard
fun addRoute(eventType: KClass<out Event>, agent: Agent)
Link copied to clipboard
fun getAgents(event: Event): List<Agent>