Options
All
  • Public
  • Public/Protected
  • All
Menu

A controller which can be used on each Coaty agent to create and/or persist Snapshot objects in time of arbitrary Coaty objects.

Available controller options (default value for all options is false):

  • shouldAdvertiseSnapshots: if true each generated Snapshot object will be advertised
  • shouldPersistLocalSnapshots: if true each Snapshot object generated will be persisted in a database collection if the database option is set with valid values
  • shouldPersistObservedSnapshots: if true each Snapshot object observed as Advertise event will be persisted in database if the database option is set with valid values; Note: local snapshots will not be observed and hereby not persisted, if shouldPersistLocalSnapshots is not additionally set to true.
  • shouldReplyToQueries: if true HistorianController will execute matching query events on the database if the database option is set with valid values
  • database: with two properties key and collection; key references the database key as defined in the databases option of your configuration; collection is the name of the collection to be used. If the collection doesn't exist, it will be created in the given database.

Hierarchy

Index

Constructors

constructor

Accessors

communicationManager

container

options

registeredName

  • get registeredName(): string
  • Gets the registered name of this controller.

    The registered name is either defined by the corresponding key in the Components.controllers object in the container configuration, or by invoking Container.registerController method with this name.

    Returns string

runtime

Methods

Protected extendLogObject

  • extendLogObject(log: Log): void
  • Whenever one of the controller's log methods (e.g. logDebug, logInfo, logWarning, logError, logFatal) is called by application code, the controller creates a Log object with appropriate property values and passes it to this method before advertising it.

    You can override this method to additionally set certain properties (such as LogHost.hostname or Log.logLabels). Ensure that super.extendLogObject is called in your override. The base method does nothing.

    Parameters

    • log: Log

      log object to be extended before being advertised

    Returns void

findSnapshotsByFilter

findSnapshotsByParentId

  • findSnapshotsByParentId(parentObjectId: string, startTimestamp?: number, endTimestamp?: number): Promise<Snapshot[]>
  • Find snapshot objects in connected database for a specific object ID which are created within a certain time period.

    The array of snapshot objects returned is ordered descendingly by creation timestamp.

    Parameters

    • parentObjectId: string

      object id from which snapshots were taken

    • Optional startTimestamp: number

      start timestamp of filter interval (optional); undefined if unrestricted

    • Optional endTimestamp: number

      end timestamp of filter interval (optional); undefined if unrestricted

    Returns Promise<Snapshot[]>

findSnapshotsByTimeFrame

  • findSnapshotsByTimeFrame(startTimestamp?: number, endTimestamp?: number): Promise<Snapshot[]>
  • Find all snapshot objects in connected database which are created within a certain time period.

    Parameters

    • Optional startTimestamp: number

      start timestamp of filter interval (optional); undefined if unrestricted

    • Optional endTimestamp: number

      end timestamp of filter interval (optional); undefined if unrestricted

    Returns Promise<Snapshot[]>

generateSnapshot

  • Create a new snapshot object of the given object with a creation timestamp set to Date.now().

    The new snapshot object will be processed according to the controller options specified. The promise returned is resolved with the created snapshot after it has been advertised and/or persisted locally.

    Note: Advertisement and persistence of snapshots are executed asynchronously. Whenever a snapshot is both persisted locally and advertised it is guaranteed that the snapshot has been stored in the database before being advertised. This also implies that Advertise events are not necessarily delivered in the same order in which snapshots were generated.

    Parameters

    • obj: CoatyObject

      Object from which the snapshot will be created

    • Rest ...tags: string[]

      String tags which can be used for filtering of (persisted) snapshot objects

    Returns Promise<Snapshot>

  • Create a new snapshot object of the given object with the given creation timestamp.

    The new snapshot object will be processed according to the controller options specified. The promise returned is resolved with the created snapshot after it has been advertised and/or persisted locally.

    Note: Advertisement and persistence of snapshots are executed asynchronously. Whenever a snapshot is both persisted locally and advertised it is guaranteed that the snapshot has been stored in the database before being advertised. This also implies that Advertise events are not necessarily delivered in the same order in which snapshots were generated.

    Parameters

    • obj: CoatyObject

      CoatyObject from which the snapshot will be created

    • timestamp: number

      creation timestamp of the snapshot

    • Rest ...tags: string[]

      String tags which can be used for filtering of (persisted) snapshot objects

    Returns Promise<Snapshot>

logDebug

  • logDebug(message: string, ...tags: string[]): void

logError

  • logError(error: any, message: string, ...tags: string[]): void
  • Advertise a Log object for an error.

    Parameters

    • error: any

      an error (object)

    • message: string

      additional error message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logErrorWithStacktrace

  • logErrorWithStacktrace(error: any, message: string, ...tags: string[]): void

logFatal

  • logFatal(error: any, message: string, ...tags: string[]): void
  • Advertise a Log object for a fatal error.

    Parameters

    • error: any

      an error (object)

    • message: string

      additional error message

    • Rest ...tags: string[]

      any number of log tags

    Returns void

logInfo

  • logInfo(message: string, ...tags: string[]): void

logWarning

  • logWarning(message: string, ...tags: string[]): void

onCommunicationManagerStarting

  • onCommunicationManagerStarting(): void

onCommunicationManagerStopping

  • onCommunicationManagerStopping(): void

onDispose

  • onDispose(): void
  • Called by the container when this instance should be disposed.

    Implement cleanup side effects here. Ensure that super.onDispose is called in your override. The base implementation does nothing.

    Returns void

onInit

  • onInit(): void
  • Called when the container has completely set up and injected all dependency components, including all its controllers.

    Override this method to perform initializations in your custom controller class instead of defining a constructor. Although the base implementation does nothing it is good practice to call super.onInit() in your override method; especially if your custom controller class does not extend from the base Controller class directly.

    Returns void

Protected onQueryReceived

  • Called whenever the Historian controller receives an incoming Query event.

    Overwrite this method in a subclass to perform some side effect. Do not call this method in your application code, it is called by the framework.

    The base method implementation does nothing. The method is only invoked when shouldReplyToQueries is set to true.

    Parameters

    Returns void

Protected onQueryRetrieved

  • Called whenever the Historian controller replies to an incoming Query with a Retrieve event.

    Overwrite this method in a subclass to perform some side effect. Do not call this method in your application code, it is called by the framework.

    The base method implementation does nothing. The method is only invoked when shouldReplyToQueries is set to true.

    Parameters

    • event: QueryEvent

      incoming Query event

    • snapshots: Snapshot[]

      array of Snapshot objects to be passed as Retrieve event data

    Returns void

querySnapshotsByParentId

  • querySnapshotsByParentId(parentObjectId: string): Observable<Snapshot[]>
  • Convenience method that queries snapshot objects for the given parent ID.

    Returns an observable of matching snapshot objects ordered descendingly by creation timestamp.

    Parameters

    • parentObjectId: string

      object id from which snapshots were taken

    Returns Observable<Snapshot[]>

Generated using TypeDoc