Interface Service

interface Service {
    isStopped: boolean;
    stopped: Promise<Error>;
    addEndpoint(name: string, opts?: ServiceHandler | Partial<Endpoint>): QueuedIterator<ServiceMsg>;
    addGroup(subject?: string, queue?: string): ServiceGroup;
    info(): ServiceInfo;
    ping(): ServiceIdentity;
    reset(): void;
    stats(): Promise<ServiceStats>;
    stop(err?: Error): Promise<Error>;
}

Hierarchy (view full)

Properties

isStopped: boolean

True if the service is stopped

stopped: Promise<Error>

A promise that gets resolved to null or Error once the service ends. If an error, then service exited because of an error.

Methods

  • The name of the endpoint must be a simple subject token with no wildcards

    Parameters

    • name: string
    • Optionalopts: ServiceHandler | Partial<Endpoint>

      is either a handler or a more complex options which allows a subject, handler, and/or schema

    Returns QueuedIterator<ServiceMsg>

  • A group is a subject prefix from which endpoints can be added. Can be empty to allow for prefixes or tokens that are set at runtime without requiring editing of the service. Note that an optional queue can be specified, all endpoints added to the group, will use the specified queue unless the endpoint overrides it. see EndpointOptions and ServiceConfig.

    Parameters

    • Optionalsubject: string
    • Optionalqueue: string

    Returns ServiceGroup

  • Returns a service info for the service

    Returns ServiceInfo

  • Resets all the stats

    Returns void

  • Returns the stats for the service.

    Returns Promise<ServiceStats>

  • Stop the service returning a promise once the service completes. If the service was stopped due to an error, that promise resolves to the specified error

    Parameters

    • Optionalerr: Error

    Returns Promise<Error>