Options
All
  • Public
  • Public/Protected
  • All
Menu

The ProcBot class is a parent class that can be used for some top-level tasks:

  • Schedule the processing of events clustered by a given context
  • Support the addition of listeners or emitters by the child class, and dispatch events to emitters
  • Retrieve configuration file from either the local FS or a ServiceEmitter

Hierarchy

Index

Constructors

constructor

  • new ProcBot(name?: string): ProcBot

Properties

Protected _botname

_botname: string

Private emitters

emitters: Map<string, ServiceMap<ServiceEmitter>> = new Map<string, ServiceMap<ServiceEmitter>>()

Private listeners

listeners: Map<string, ServiceMap<ServiceListener>> = new Map<string, ServiceMap<ServiceListener>>()

Protected logger

logger: Logger = new Logger()

Private nodeBinPath

nodeBinPath: string

Methods

Private addService

  • addService(type: ServiceType, name: string, data?: ServiceConstructor): ServiceListener | ServiceEmitter | void
  • Create a new ServiceListener or ServiceEmitter. Uses the passed name or handle as the indentifier for future creation/lookups. Should an instance with the handle (or name) already exist then this will be passed back.

    Parameters

    • type: ServiceType

      Type of Service to create.

    • name: string

      Name of the service to create.

    • Optional data: ServiceConstructor

      ServiceBase extended constructor, giving an optional handle and constructor data.

    Returns ServiceListener | ServiceEmitter | void

    A ServiceListener, ServiceEmitter or void value.

Protected addServiceEmitter

  • addServiceEmitter(name: string, data?: any): ServiceEmitter | void
  • Add a new type of ServiceEmitter to the client. Should the ServiceEmitter already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceEmitter to add.

    • Optional data: any

    Returns ServiceEmitter | void

    The constructed or pre-existing ServiceEmitter or void on failure.

Protected addServiceListener

  • addServiceListener(name: string, data?: any): ServiceListener | void
  • Add a new type of ServiceListener to the client. Should the ServiceListener already exist on the client with the handle/name, this will do nothing.

    Parameters

    • name: string

      The name of the ServiceListener to add.

    • Optional data: any

    Returns ServiceListener | void

    The constructed or pre-existing ServiceListener or void on failure.

Protected dispatchToAllEmitters

  • dispatchToAllEmitters(data: ServiceEmitRequest): Promise<any[]>
  • Dispatch to the specified emitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    Parameters

    • data: ServiceEmitRequest

      The ServiceEmitRequest to use. This will be dispatched to all ServiceEmitters.

    Returns Promise<any[]>

    An array of ServiceEmitResponses from all the ServiceEmitters.

Protected dispatchToEmitter

  • dispatchToEmitter(handle: string, data: any): Promise<any>
  • Dispatch to a specific ServiceEmitter. This method exists as a shortcut to avoid having to retrieve a specific emitter before sending to it.

    throws

    Any error returned from the service represented by the ServiceEmitter.

    Parameters

    • handle: string

      The handle of the ServiceEmitter to dispatch to.

    • data: any

      Emitter appropriate data to send.

    Returns Promise<any>

    Data returned from the service represented by the ServiceEmitter.

Protected getEmitter

  • getEmitter(handle: string): ServiceEmitter | void
  • Find a particular attached ServiceEmitter based upon its name.

    Parameters

    • handle: string

      Handle of the ServiceEmitter instance to find (name if no handle was set).

    Returns ServiceEmitter | void

    Instance of the ServiceEmitter found, or void if not found.

Protected getListener

  • getListener(handle: string): ServiceListener | void
  • Find a particular attached ServiceListener based upon its handle.

    Parameters

    • handle: string

      Handle of the ServiceListener instance to find (name if no handle was set).

    Returns ServiceListener | void

    Instance of the ServiceListener found, or void if not found.

getNodeBinPath

  • getNodeBinPath(): Promise<string>
  • Retrieve the binary path for the Node dependencies.

    Returns Promise<string>

    A string containing the absolute path.

Private getService

  • getService(name: string): ServiceFactory
  • Retrieves and loads a ServiceListener or ServiceEmitter by name.

    Parameters

    • name: string

      The name of the ServiceListener or ServiceEmitter to load.

    Returns ServiceFactory

    The relevant ServiceFactory for the service.

Protected processConfiguration

  • processConfiguration(configFile: string): ProcBotConfiguration | void
  • Process a configuration file from YAML into a nested object.

    Parameters

    • configFile: string

      The configuration file as a string.

    Returns ProcBotConfiguration | void

    The configuration object or void.

Protected retrieveConfiguration

  • retrieveConfiguration(details: ConfigurationLocation): Promise<ProcBotConfiguration | void>
  • Retrieve a ProcBotConfiguration file from a ServiceEmitter or inbuilt route.

    Parameters

    • details: ConfigurationLocation

      An object detailing the service to retrieve the configuration file from, and its location.

    Returns Promise<ProcBotConfiguration | void>

    A Promise containing configuration object should one have been found, or void.

Generated using TypeDoc