A Location Service Client API. This model provides promise based APIs for managing service registrations.

interface LocationService {
    find(connection: Connection): Promise<Option<Location>>;
    list(): Promise<Location[]>;
    listByComponentType(componentType: ComponentType): Promise<Location[]>;
    listByConnectionType(connectionType: ConnectionType): Promise<Location[]>;
    listByHostname(hostname: string): Promise<Location[]>;
    listByPrefix(prefix: Prefix): Promise<Location[]>;
    resolve(
        connection: Connection,
        within: number,
        unit: TimeUnit,
    ): Promise<Option<Location>>;
    track(
        connection: Connection,
    ): (
        onEvent: (trackingEvent: TrackingEvent) => void,
        onError?: (error: ServiceError) => void,
        onClose?: () => void,
    ) => Subscription;
    unregister(connection: Connection): Promise<"Done">;
}

Methods

  • List the registered components based on the hostname. Hostname can be IP or URL.

    Parameters

    • hostname: string

      list components of this hostname

    Returns Promise<Location[]>

    Location[] as Promise

  • Resolves the location for a connection, if not found waits for the event to arrive within specified time limit. Returns undefined if both failed.

    Parameters

    • connection: Connection

      The Connection to be located

    • within: number

      Time within which the connection to be resolved

    • unit: TimeUnit

      TimeUnit Ex: millis, seconds, hours, etc.

    Returns Promise<Option<Location>>

    Location as Promise if available