@arkade-os/sdk Documentation - v0.5.0-rc.11
    Preparing search index...

    Interface MessageHandler<REQ, RES>

    interface MessageHandler<
        REQ extends RequestEnvelope = RequestEnvelope,
        RES extends ResponseEnvelope = ResponseEnvelope,
    > {
        messageTag: string;
        handleMessage(message: REQ): Promise<RES | null>;
        isLongRunning?(message: REQ): boolean;
        start(
            services: {
                arkProvider: ArkProvider;
                readonlyWallet: ReadonlyWallet;
                wallet?: Wallet;
            },
            repositories: { walletRepository: WalletRepository },
            channel?: { broadcast(response: RES): void },
        ): Promise<void>;
        stop(): Promise<void>;
        tick(now: number): Promise<RES[]>;
    }

    Type Parameters

    Implemented by

    Index

    Properties

    messageTag: string

    A unique identifier for the updater. This is used to route messages to the correct updater.

    Methods

    • Optional opt-out from the bus-level message timeout.

      Long-running flows (e.g. settlement) surrender control to remote peers and can legitimately sit idle for longer than messageTimeoutMs. When this returns true, the bus awaits handleMessage without a deadline. Defaults to false.

      Parameters

      Returns boolean

    • Called once when the SW is starting up

      Parameters

      • services: { arkProvider: ArkProvider; readonlyWallet: ReadonlyWallet; wallet?: Wallet }

        Providers and wallet instances available to the handler.

      • repositories: { walletRepository: WalletRepository }

        Repositories available to the handler.

      • Optionalchannel: { broadcast(response: RES): void }

        Push channel to clients, for responses that answer no request. Use it instead of holding events for the next tick. The channel is scoped to the generation it was handed out in: after a bus re-init or stop() it goes inert on its own, so retaining one past stop() cannot post.

      Returns Promise<void>

    • Called by the scheduler to perform a tick. Can be used by the updater to perform periodic tasks or return delayed responses (eg: subscriptions).

      Parameters

      • now: number

        The current time in milliseconds since the epoch.

      Returns Promise<RES[]>