Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ServiceDiscovery<S>

API for discovering different services using a variety of protocols. This API provides a simple contract that a consumer can use without knowing the full details about the underlying discovery service.

Type parameters

Hierarchy

Implemented by

Index

Properties

Readonly destroyed

destroyed: boolean

Get if this discovery has been destroyed.

Readonly onAvailable

onAvailable: Subscribable<ServiceDiscovery<S>, [service: S]>

Event emitted whenever a service is detected as available.

Readonly onDestroy

onDestroy: Subscribable<ServiceDiscovery<S>, []>

Event called whenever this discovery is destroyed.

Readonly onError

onError: Subscribable<ServiceDiscovery<S>, [err: Error]>

Event emitted when an error occurs for this discovery.

Readonly onUnavailable

onUnavailable: Subscribable<ServiceDiscovery<S>, [service: S]>

Event emitted whenever a service is detected to be unavailable.

Readonly onUpdate

onUpdate: Subscribable<ServiceDiscovery<S>, [service: S, previousVersion: S]>

Event emitted when a service is available and is updated.

Readonly services

services: S[]

Get a copy of the current services.

Methods

and

destroy

  • destroy(): Promise<void>
  • Destroy this discovery. This should be called whenever the discovery is no longer needed. Destroying a discovery will ensure that no more events are triggered and that resources used by the discovery are released.

    Returns Promise<void>

filter

  • Filter the services discovered. This creates a new instance in which only services that pass the predicate function are available.

    The filtered discovery is only valid as long as this discovery is not destroyed. Calling destroy() on this discovery will destroy the filtered discovery.

    Parameters

    • predicate: ServicePredicate<S>
      • predicate used to filter items, if this function returns true the service will be available in the filtered results

    Returns ServiceDiscovery<S>

find

findAll

  • Find all of the services that match the given predicate. Will return an array with all of the matching services.

    Parameters

    Returns S[]

get

  • get(id: string): null | S

map

Generated using TypeDoc