Archivist core module
This module can be used to access things such as topic configuration and vault backends.
Used to confirm the abilities of the topic on this configured system
Not all vaults can implement the full spectrum of internals required by the higher level APIs; this method allows developers to verify whether a given vault backend support the functionalities it needs.
Close all vaults instances
Retrieve an object containing all the existing vault backend instances
Retrieve a map of all existing topics
Migrate all current vaults to a given version
This will look at the list of available migration scripts and execute them if needed.
Check if a topic is defined
Configuration core module
HTTP Server
This API can be used to add your own custom routes if needed, as well as to serve files. This can be useful during the development of an HTML5 game.
Register a route (a string or a regular expression) on the HTTP server
Incoming requests will be expected to be handled by the handler function you pass. Based on the type you specify, your handler function will receive different arguments.
url.parse()
.The callback accepts the following arguments in order:
ws
documentation.url.parse()
.url.parse()
.Your handler function must return an endpoint object to connect to.
For syntax, please read the net.createConnection()
documentation.
Removes the handler function registered on the given route.
Registers a route to lead directly to a file on disk
If you want to be notified when a request finishes, you may pass
an onFinish
function. It may receive an error as its first argument.
If you decide to pass this function, logging the error will be your responsibility.
Registers a route to lead directly to a folder on disk
If you want to be notified when a request finishes, you may pass
an onFinish
function. It may receive an error as its first argument.
If you decide to pass this function, logging the
error will be your responsibility.
Example:
mage.core.httpServer.serveFolder('/source', './lib');
If you provide a defaultFile
file name argument, serving up a
folder by its name will serve up a default file if it
exists.
Example:
mage.core.httpServer.serveFolder('/source', './lib', 'index.html');
Registers a route "/favicon.ico" and serves the given buffer as content
The mime type defaults to image/x-icon
and may be overridden.
The core logger is the logger instance used internally
by MAGE to log different events; for your application,
you should most likely use mage.logger
instead
Message Server
The message server is used for state propagation across multiple MAGE servers in a cluster; it can also be used directly by MAGE developer to transfer data across servers.
Message Server
Broadcast a message to all connected Message Server instance
Close the network connection for this Message Server
Send a confirmation message
Mark a given address as connected
Mark a given address as disconnected
Retrieve the unique cluster identifier
Retrieve the underlying MMRP Node instance used by this Message Server instance.
Retrieve the configuration used by this Message Server instance
Check whether the Message Server is enabled
See https://mage.github.io/mage/api.html#subsystems for mor details on how to enable message server.
Send a message to a remote Message Server instance
Sampler core module
Used for keeping tracks of local server metrics. This is useful for when you wish to expose some information about your server in production (for Zabbix, Nagios, Grafana, etc).
See https://mage.github.io/mage/#metrics for more details.
Increment a given metric
Keep track of a value
When accessing the savvy HTTP interface to collect the data point created by this method, you will have access to:
See https://www.npmjs.com/package/panopticon#panopticonsamplepath-id-n
Set the value of a given metric
Keep track of a value over a period of time
Works similarly to mage.sampler.sample
, but let the user pass
a time delta value.
See https://www.npmjs.com/package/panopticon#panopticontimedsamplepath-id-dt
The Service Discovery library is a library that allows you to announce and discover services on the local network, through different types of engines.
To use service discovery, configuration is mandatory; See https://mage.github.io/mage/#service-discovery to learn how to configure service discovery.
Create a service instance
Service instances can be used to announce services as well as listen for service instance appearing and disappearing.
State class
The state library exposes a constructor that constructs objects which form an interface between an actor, a session and the archivist. Virtually any command that involves reading and modification of data should be managed by a state object.
When you’re done using the state class, always make sure to clean it up by calling close() on it. MAGE’s module and command center systems that bridge the communication between client and server use the State object for API responses and server-sent events.
{{ new(): mage.core.IState }}