Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ReleaseableServiceDiscovery<S>

Extension to ServiceDiscovery that supports releasing its resources.

destroy() is designed so that a discovery that depends on other discoveries, such as filtered discoveries, destroy the discoveries they depend on. This is to make it easier to create filtered and mapped chains and then ignore the root discovery.

In some cases you want to keep the original discoveries around, in which case you can call release() to destroy only this discovery and not the ones it depends on.

Type parameters

Hierarchy

Implemented by

Index

Properties

Readonly destroyed

destroyed: boolean

Get if this discovery has been destroyed.

Readonly onAvailable

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

Event emitted whenever a service is detected as available.

Readonly onDestroy

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

Event called whenever this discovery is destroyed.

Readonly onError

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

Event emitted when an error occurs for this discovery.

Readonly onUnavailable

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

Event emitted whenever a service is detected to be unavailable.

Readonly onUpdate

onUpdate: Subscribable<ReleaseableServiceDiscovery<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

get

  • get(id: string): null | S

map

release

  • release(): Promise<void>
  • Release the resources used by this discovery, without destroying discoveries it depends on.

    This will mark this discovery as destroyed.

    Returns Promise<void>

Generated using TypeDoc