Cohorte platform is based on Herald Framework for the discovery and transport between the different isolates. However, Herald is a completely seperate project which could be used for your own cases.
Herald abstarct the transport protocols used between peers (communicating entities), and allows each peer to send message to one or more peers by just knowing its UID (or the group name).
This documentation is about
Herald Specification v1.
This specification is split into this chapters:
- Chapter 1 - Introduction
- Chapter 2 - Terminology
- Chapter 3 - Message Format
- Chapter 4 - Sending Messages
- Chapter 5 - Receiving Messages
- Chapter 6 - Transport
- Chapter 7 - Discovery
- Chapter 8 - Using Herald
- Chapter 9 - Implementations
- Chapter 10 - Extending Herald
|OSGi||Specification for modular and dynamic applications based on service-oriented approach (see http://osgi.org).|
|Peer||Represents one OSGi node (runtime). It has a unique UID (Universal IDentifier) and a symbolic name.|
|Group||A set of Peers regrouped logically in one group. A peer can be associated to several groups.|
|Access||Supported protocols for one peer. Two peers should have the same access type to communicate.|
|Message||Object containing the data to be transported and metadata useful for the framework or user needs.|
|Directory||Internal storage on each peer that has information about discovered peers and their capabelities.|
|Discovery||Operation on which a peer discover other peers of the same application (having same AppID). Their information is stocked on the local Directory.|
|Transport||Communication protocol used to transport messages between peers.|
|AppID||An application ID is associated to each peer: only peers with the same application ID can discover each other.|
Herald Message is a JSON object with the following structure :
Here is a description and semantic of each of this entries :
Each message has a map of standard headers about the message. This headers are set by the framework and not by users. In case of a newly sent message, we have :|
a String identifying the purpose of the message. It is recommended to use URI (Uniform Resource Identifier) syntax. E.g., |
|metadata||a map of extra informations (user-specific).|
Message class encapsulates Herald JSON message. It is defined in the module
The following snipet shows the constructor's code of this class in Python programming language.The
Message's constructor automatically initializes basic headers including message uid, its timestamp, and the Herald's specification version.
Each message has a set of Headers (set by the framework), a subject and a content (set by the user). The content could be of any primitive type or a serializable bean object. In addition, user can add a set of metadata associated to the message’s content. All the headers, subject, content, and the metadata are transmitted to the targeted peer.
The Message class has the following methods to retreive and set those informations.
Herald Transports can take the exported data and send it using protocol specific transport.
At the other side, Herald Transports can construct a
Message object from the received JSON data (serialization of the
There are several ways to send Herald message depending on the need of the sender.
fire: Fires (and forget) the given message to the target
fire_group: Fires (and forget) the given message to the given group of peers
send: Sends a message, and waits for its reply
post: Posts a message. The given methods will be called back as soon as a result is given, or in case of error
post_group: Posts a message to a group of peers. The given methods will be called back as soon as a result is given, or in case of error
All this methods are defined in
herald/core.py and are exported as a service
This method will looks for the supported accesses on the target peer, and uses the corresponding local accesses of the local peer to send the message. The sending operation is delegated to the transport module associated with each access. This method returns immediatly.
This method will looks for all peers of the targeted group, and send a copy of the message for each one. It returns a tuble consisting of the UID of the message sent and the list of peers.
This method is similar to
fire but the caller remains blocked until a response is returned back.
This method is similar to
Sendbut the caller does not remain blocked. This method returns immediatly and the provided callback method will be called when an answer is received.
Post but the message will be sent for all peers of the targeted group.
This method is called to return a reply message to the original peer.
All peers of the same application (having same AppID) are discovered by Herald. This is done by Transport providers implementing specific discovery techniques.
What ever the discovery technology used by transport providers, they should all respect the following protocol :
When a peer L (local) detects another peer D (discovered) :
L sends a message to D containing a description about thim (L_dump) and having
D saves L_dump on his local directory without notifying other listeners about this message arrival.
D sends a message to L containing its description (D_dump) and having
L saves D_dump on his local directory and notifies Herald about this new discovered peer. It is now accessible and messages could be sent to it.
L sends a message to D to finish the discovery synchronization, it has
D receives this message and notifies Herald about this new discovered peer.
Herald is used as Service in an OSGi platform runtime.
- herald… (transports, discovery, etc)
This configurations are used by Herald Directory to create a local Peer.
Binding to Herald Services
To retrieve information about peers.
To send messages.
In HTTP protocol, Herald uses HTTP Multicast to discover other peers.
1) herald/rpc/discovery/add 2) herald/directory/discovery/step1 3) herald/directory/discovery/step3
- initial discovery
- knowledge propagation
- remote services
How to implement a new discovery protocol?
How to implement a new transport protocol?
Each specific transport should provide the service
herald.SERVICE_TRANSPORT. This service has the following methods that should be implemented:
comments powered by Disqus