The SAYMON architecture allows users to develop server extensions, that add to SAYMON the functionality the users need. An example of such functionality may be additional data collectors that quering special equipment or modules that send notifications to channels that a customer needs (for instance, syslog or Jabber chat).

Each user extension is an actor written in JavaScript or TypeScript. This actor is loaded by the SAYMON server at startup. All internal APIs that are used inside the SAYMON server are available to it.

For more information on how to develop server extensions — actors — see in the examples of this section.

Actors

Actor is a module that can:

The main property of the actor is its complete isolation from other modules and the ability to communicate with these modules only via messages. It allows to scale actors flexibly, depending on the load.

SAYMON server uses the actor model for server extensions, since it itself is implemented according to the actor model. The Comedy library is used as an implementation of the actor model. To develop server extensions it is essential to be familiar with this library.

Example

The simplest example of a custom extension is a module that sends greeting to a log. This example is as follows:

class HelloWorldActor {
  initialize(selfActor) {
    selfActor.getLog().info('Hello, world!');
  }
}


module.exports = HelloWorldActor;

In order to load the above module into SAYMON, it is necessary to:

{
  ...,
  "server": {
    ...,
    "extension_path": "/tmp/saymon-modules"
  },
  ...
}

To apply changes the service saymon-server must be restarted:

sudo service saymon-server restart

After that, the following message will appear in the SAYMON server log:

Thu Dec 20 2018 11:46:04 GMT+0300 - info: InMemoryActor(5c1b56ccf06c7b030664ff5b, HelloWorldActor): Hello, world!