@botmesh/core - v2.0.0-alpha.2
    Preparing search index...

    Interface Coordinator

    Cross-replica coordination backend. One instance per replica (per Bot); the bot calls start when it starts and stop when it stops.

    interface Coordinator {
        replicaId: string;
        start(): Promise<void>;
        stop(): Promise<void>;
        reserve(key: string): Promise<Ticket>;
        acquireTurn(ticket: Ticket, opts?: AcquireTurnOptions): Promise<ChatTurn>;
        lead(name: string, opts?: { signal?: AbortSignal }): Promise<Leadership>;
        tryLead(name: string): Promise<Leadership | null>;
        on<E extends keyof CoordinatorEvents>(
            event: E,
            listener: (payload: CoordinatorEvents[E]) => void,
        ): () => void;
    }

    Implemented by

    Index
    replicaId: string

    This replica's id; unique among the replicas sharing the backend.

    • Release every turn and leadership this replica holds and stop renewing (idempotent).

      Returns Promise<void>

    • Reserve a place in key's cross-replica FIFO. The bot calls it in ingress order.

      Parameters

      • key: string

      Returns Promise<Ticket>

    • Campaign for name until elected (or opts.signal aborts, rejecting).

      Parameters

      • name: string
      • Optionalopts: { signal?: AbortSignal }

      Returns Promise<Leadership>