Options
All
  • Public
  • Public/Protected
  • All
Menu

Supports rule-based routing of data from IO sources to IO actors based on an associated IO context.

Define rules that determine whether a given pair if IO source and IO actor should be associated or not. A rule is only applied if the value type of IO source and IO actor are compatible. If no rules are defined or no rule matches no associations between IO sources and IO actors are established.

You can define global rules that match IO sources and actors of any compatible value type or value-type specific rules that are only applied to IO sources and IO actors with a given value type.

By default, an IO source and an IO actor are compatible if both define equal value types in equal data formats. You can define your own custom compatibility check on value types in a subclass by overriding the areValueTypesCompatible method.

Note that this router makes its IO context available by advertising and for discovery (by core type, object type, or object Id) and listens for Update-Complete events on its IO context, triggering onIoContextChanged automatically.

This router requires the following controller options:

  • ioContext: the IO context for which this router is managing routes (mandatory)
  • rules: an array of rule definitions for this router. The rules listed here override any rules defined in the onInit method.

Hierarchy

Index

Constructors

constructor

Accessors

communicationManager

container

ioContext

managedIoNodes

  • get managedIoNodes(): Readonly<Map<string, IoNode>>

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 areValueTypesCompatible

  • Checks whether the value types and value data formats of the given IO source and actor match.

    This is a precondition for associating IO source and actor.

    The base implementation returns true, if the given source value type is identical to the given actor value type and both value data formats (either raw binary or JSON) match; otherwise false.

    Override this base implementation if you need a custom value type compatibility check in your router.

    Parameters

    Returns boolean

Protected associate

Protected computeDefaultUpdateRate

  • The default function used to compute the recommended update rate of an individual IO source - IO actor association.

    This function takes into account the maximum possible update rate of the source and the desired update rate of the actor and returns a value that satisfies both rates.

    Override this method in a subclass to implement a custom rate function.

    Parameters

    Returns number

defineRules

  • Define all association rules for routing.

    Note that any previously defined rules are discarded.

    Rules with undefined condition function are ignored.

    Parameters

    Returns void

Protected disassociate

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

findManagedIoNode

  • findManagedIoNode(predicate: (node: IoNode) => boolean): IoNode

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
  • Called when the communication manager is about to start or restart.

    Override this method to implement side effects here. Ensure that super.onCommunicationManagerStarting is called in your override. The base implementation does nothing.

    Returns 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

onIoContextChanged

  • onIoContextChanged(): void

Protected onIoNodeManaged

  • onIoNodeManaged(node: IoNode): void

Protected onIoNodesUnmanaged

  • onIoNodesUnmanaged(nodes: IoNode[]): void

Protected onStarted

  • onStarted(): void

Protected onStopped

  • onStopped(): void

Generated using TypeDoc