Class Manager<PortClient, PortConfig, PortInstance>

Provider Manager wraps a specific port created by the extension of the Port abstract class, instrumenting it with the necessary logic to manage:

class diagram

  • Merge and validate the configuration of the provider represented by the generic type PortConfig. The manager configuration object ProviderOptions has a validation property that represent a structure of type PortConfigValidationStruct where default values, environment based and a Joi validation object are defined. During the initialization process, the manager will merge all the sources of configuration (default, environment and specific) and validate the result against the Joi schema. So, the order of priority of the configuration sources is: specific, environment and default. If the validation fails, the manager will use the default values and emit an error that will be managed by the observability layer.

Port class, this is, the class that extends the Port abstract class

Type Parameters

  • PortClient

    Underlying client type, this is, the real client of the wrapped provider

  • PortConfig

    Port configuration object, could be an extended version of the client config

  • PortInstance extends Layer.Provider.Port<PortClient, PortConfig>

Hierarchy

  • EventEmitter
    • Manager

Implements

Constructors

Properties

componentId: string

Provider unique identifier for trace purposes

config: PortConfig

Port configuration

Accessors

  • get date(): string
  • Timestamp of actual state in ISO format, when the current state was reached

    Returns string

  • get error(): undefined | Multi | Crash
  • Return the errors in the provider

    Returns undefined | Multi | Crash

  • get name(): string
  • Provider name

    Returns string

  • get state(): "error" | "running" | "stopped"
  • Provider state

    Returns "error" | "running" | "stopped"

  • get status(): "pass" | "fail" | "warn"
  • Provider status

    Returns "pass" | "fail" | "warn"

Methods

  • Add a listener for the error event, emitted when the component detects an error.

    Parameters

    • event: "error"

      error event

    • listener: (error: Multi | Crash) => void

      Error event listener

    Returns this

  • Add a listener for the status event, emitted when the component changes its status.

    Parameters

    • event: "status"

      status event

    • listener: (status: ProviderStatus) => void

      Status event listener

    Returns this

  • Close the provider: release resources, connections ...

    Returns Promise<void>

  • Error state: wait for new state of to fix the actual degraded stated

    Parameters

    • error: Error | Crash

      Cause ot this fail transition

    Returns Promise<void>

  • Removes the specified listener from the listener array for the error event.

    Parameters

    • event: "error"

      error event

    • listener: (error: Multi | Crash) => void

      Error event listener

    Returns this

  • Removes the specified listener from the listener array for the status event.

    Parameters

    • event: "status"

      status event

    • listener: (status: ProviderStatus) => void

      Status event listener

    Returns this

  • Add a listener for the error event, emitted when the component detects an error.

    Parameters

    • event: "error"

      error event

    • listener: (error: Multi | Crash) => void

      Error event listener

    Returns this

  • Add a listener for the status event, emitted when the component changes its status.

    Parameters

    • event: "status"

      status event

    • listener: (status: ProviderStatus) => void

      Status event listener

    Returns this

  • Add a listener for the error event, emitted when the component detects an error. This is a one-time event, the listener will be removed after the first emission.

    Parameters

    • event: "error"

      error event

    • listener: (error: Multi | Crash) => void

      Error event listener

    Returns this

  • Add a listener for the status event, emitted when the component changes its status. This is a one-time event, the listener will be removed after the first emission.

    Parameters

    • event: "status"

      status event

    • listener: (status: ProviderStatus) => void

      Status event listener

    Returns this

  • Removes all listeners, or those of the specified event.

    Parameters

    • Optionalevent: "error"

      error event

    Returns this

  • Removes the specified listener from the listener array for the error event.

    Parameters

    • event: "error"

      error event

    • listener: (error: Multi | Crash) => void

      Error event listener

    Returns this

  • Removes the specified listener from the listener array for the status event.

    Parameters

    • event: "status"

      status event

    • listener: (status: ProviderStatus) => void

      Status event listener

    Returns this

  • Initialize the process: internal jobs, external dependencies connections ...

    Returns Promise<void>

  • Stop the process: internal jobs, external dependencies connections ...

    Returns Promise<void>