Modules

A Brain4it module is an application than runs inside a Brain4it server.

Important things you need to know about modules:

  • Manager applications allow you to create and destroy a module through the REST API of a Brain4it server. The server access key is required to perform these operations. See the server setup to find out how to change the server access key.
  • A module has a unique name within the server.
  • It contains the code and data (lists and literals) of the application.
  • Its content is isolated from other modules.
  • All elements inside a module (lists and literals) can be referenced by a URL.
  • The HTTP GET, PUT and DELETE methods of the REST API of a Brain4it server allow you to read, write and delete any content of the module. To call these methods the module access key (or server access key) must be specified in the Access-Key request header. If no access key is specified, the module content can not be read or modified. The value of the module access key is defined by the access-key variable.
  • A module may have exterior functions that expose some functionality of the application. These functions are easily recognizable because their name starts with the at symbol (@). No access key is required to invoke an exterior function, but it may implement other security mechanisms instead (like basic authentication).
  • The values returned by exterior functions can be monitored efficiently through the REST API.
  • A module could have one o more dashboards. A dashboard is a user interface that contains widgets (like buttons, sliders, displays, etc.) to show information or send orders to the module by calling its external functions. See the dashboard design guide to learn how to create a dashboard.
  • Snapshots of the module content can be generated and saved in persistent storage with the module-save function. These snapshots can be loaded into the module memory with the module-load function. Consult the module library to know more about these functions.
    Each snapshot has a unique name within the module. By default that name is "head".
    When the server is stopped, all its modules are saved automatically as the "head" snapshot. When the server is started again, all its modules are loaded with the content of its "head" snapshot.
  • The desktop manager application can import and export module snapshots represented as text files. These snapshots can be imported later into modules of the same or other servers.
  • When a module is started (at server startup), the code of the start variable is evaluated to perform initialization tasks.
  • When a module is stopped (at server shutdown), the code of the stop variable is evaluated to perform cleanup tasks. After that, any running executor in this module is interrupted.
brain4it module structure
Top