Instrumentation
In order to gain control over the distributed system, Netrix requires
- Replicas to communicate messages and events through it. The send and receive primitives of the replicas should now communicate with Netrix.
- Ability to start, stop or reset replicas. Netrix sends
Directivemessages to achieve this. Replicas should perform the requested action when they receive aDirectivemessage.
Libraries
To aid this process, we have language specific libraries. Currently available for go.
Directives
Directive messages are used by Netrix to instruct replicas to start, stop or reset. Message structure contains just the action
DirectiveMessage {
Action string
}
Replica API spec
Each replica should run a HTTP server and publish the address of that server to Netrix. The API endpoints are
/messagereceives theMessageobject serialized as json in aPOSTrequest. Should respond with status200to acknowledge message reception./directivereceives theDirectiveMessageserialized as json in aPOSTrequest. Should respond with status200after completing the requested action./health:GETrequest is called to check the availability of the replica. Should respond with200to confirm availability.
Communicating with Netrix
Replicas should persist a HTTP connection to Netrix API endpoint. This connection should be used to send replica information, events and messages. See API documentation for details about API.
Before any request is made, replica should call the /replica API endpoint with the following information
Replica {
ID string
Ready bool
Info map[string]any
Addr string
}
Readyis used to indicate if the replica is ready to send and receive messages. Netrix will wait for all replicas to be ready before continuing.Addrshould be Replica API endpoint that Netrix will use to communicate messages and directives.Infocan be any additional information. This information can be used when writing unit tests. For example, replicas can submit their private keys such that unit tests can change the contents of messages originating from this replica.
Following this call the replica should use the same ID when sending messages and events.