Skip to content
Français

createObservationHub

import { createObservationHub } from "@elie-laloum/outpost";

Create a root hub that stamps every event with one shared sequence and delivers a copy to each sink through its own bounded queue. Pass it as observation to a workflow or dispatch: runs emit through scoped children, and you own and close the root. Sink failures and losses are collected, never thrown; the hub stores nothing.

Complete example and detailed rules.

  • optionsOptional
    ObservationHubOptions | undefined
    Receivers, initial scope, delivery limits and opt-in model payload verbosity.
  • options.sinksOptional
    readonly ObservationSink[] | undefined
    Receivers attached to this root and inherited by every child.
  • options.scopeOptional
    ObservationScope | undefined
    Initial correlation fields; child scopes override only explicitly supplied fields.
  • options.capacityOptional
    number | undefined
    Maximum events waiting per asynchronous sink, default 1024; on overflow the newest are dropped and counted. A value that is not a positive integer throws.
  • options.deliveryTimeoutMsOptional
    number | undefined
    Maximum wait for one asynchronous delivery or sink flush, default 5000; a sink that exceeds it is disabled for the hub’s lifetime. A value that is not a positive integer throws.
  • options.verboseOptional
    boolean | undefined
    Explicitly allow full model request/response events. Does not enable verbose journal retention by itself.

ObservationHub

export declare function createObservationHub(
  options?: ObservationHubOptions,
): ObservationHub;