A resource is extended component that represent the access to an external/internal resource, besides the error handling and identity, it has a start, stop and close methods to manage the resource lifecycle. It also has a checks property to define the checks that will be performed over the resource to achieve the resulted status. The most typical example of a resource are the Provider that allow to access to external databases, message brokers, etc.

Hierarchy

  • EventEmitter
    • Registry

Implements

Constructors

  • Creates a new Register instance

    Parameters

    • name: string

      Component name

    • maxInactivityTime: number = Constants.DEFAULT_MAX_INACTIVITY_TIME

      Max time in minutes that a job could be pending state

    • registerLimit: number = Constants.DEFAULT_MESSAGES_REGISTERS_LIMIT

      Maximum number of entries in the message register

    Returns Registry

Properties

componentId: string = ...

Component identification

executedJobs: CommandJobDone[] = []

Processed jobs

messages: Message[] = []

Array of messages used as fifo register

name: string

Component name

pendingJobs: Map<string, CommandJobHandler> = ...

Pending commands

Accessors

  • get status(): "pass" | "fail" | "warn"
  • Return the status of the register

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

Methods

  • Perform the cleaning of all the resources

    Returns void

  • Fake close method used to implement the Resource interface

    Returns Promise<void>

  • Add a new job to the registry of the jobs managed by this consumer

    Parameters

    Returns void

  • Add a new message to the registry of the last messages managed by this consumer

    Parameters

    • message: Message

      message to be added

    Returns void

  • Fake start method used to implement the Resource interface

    Returns Promise<void>

  • Fake stop method used to implement the Resource interface

    Returns Promise<void>