Interface Dispatcher
interface Dispatcher {
add(reporter: Reporter): void | Promise<void>;
dispatch(event: Event): void | Promise<void>;
setGlobalMetadata(key: string, value: PlainValue): void | Promise<void>;
}
add(reporter: Reporter): void | Promise<void>;
dispatch(event: Event): void | Promise<void>;
setGlobalMetadata(key: string, value: PlainValue): void | Promise<void>;
}
Implemented by
Methods
add
dispatch
set Global Metadata
-
Passes one entry of the journey's global metadata on.
Parameters
- key: string
- value: PlainValue
Returns void | Promise<void>
Delivers the events and the global metadata of one journey to the reporters added to it.
An executor gets a new dispatcher for every journey from its DispatcherFactory, adds the journey's reporters to it, sets every entry of the journey's global metadata and dispatches every event of the journey through it, and drops it when the journey ends. What adding a reporter means, and how events and global metadata are delivered, is the dispatcher's own decision; DefaultDispatcher is the usual one. Whatever the dispatcher does, the executor keeps a reporter that failed from receiving anything more, and every other reporter from receiving anything but
journey_aborted.Each operation may be synchronous or asynchronous. Failing in
add, or insetGlobalMetadatabefore the journey starts, refuses the journey; failing indispatch, or insetGlobalMetadatawhile the journey runs, aborts it withreporter failed, except whilejourney_abortedis dispatched, when the failure is ignored.