With nano services, we implement several patterns at once:
- The abstraction of a small service that consists only of a single message, and whose implementation remains private. You send a message to a nano service wherever it is implemented.
- The observer pattern is used to notify interested targets about states of the node. All observers that stick to a nano service get the notification.
- You can monitor a nano service by attaching an observer to the nano service. You will then receive the same message as the owner of the nano service.
What does a nano service consist of?
A nano service consists of a record ID and a short description. It is registered at the nano service registry of a namespace, but can of course also be accessed from outside the namespace and even from other nodes. Services that affect the whole node are registered in the "SYSTEM" namespace.
The record description also describes the nano service. A record is described via a JSON or XML file.
Observers are target addresses, meaning addresses of targets that receive messages addressed to the nano service.
Therefore, nano services can be accessed from anywhere in
How can I send a message to a nano service?
Target addresses consist of a target ID and a namespace address.
Messages have a receiver address in the envelope. If the target ID is missing in this address, the message cannot be delivered to a target directly. The system therefore sends the message to the namespace described by the rest of the address. The namespace checks whether a nano service with the record ID of the message has been registered in the nano service registry of the namespace. If this is the case, a copy of the message is sent to all observers of the nano service. In the other case, the message is returned with an error code.
All you need to do is set a receiver address where the target ID is missing and the namespace address is is filled in.