The Elko Repository Protocols
The Repository
The Repository is an Elko server that provides persistent storage for objects. Context servers can be configured to use either a local repository that they access directly or to communicate with a Repository server. The protocols described here are for the latter case.
A Repository understands two different JSON message protocols. These correspond to the two kinds of actors who may wish to communicate with a Repository: other servers seeking to retrieve or store persistent objects, and administrators. Each of the ports that a Repository listens for connections on can be configured to support either or both of these protocols.
Each of these protocols is associated with a particular object ref to which messages should be addressed:
repfor object repository access.adminfor administrator messages.
Repository Protocol
The repository protocol is used by clients who wish to access the persistent objects that the Repository manages.
get
→ { to:"rep", op:"get", what:[REQUESTDESC], tag:?STR }
This message requests the retrieval of the persistent state of one or more objects.
whatis an array of object request descriptors specifying the objects whose retrieval is sought.tagis an optional tag string that, if given, will be sent back with the response(s), to help the client match up requests and responses.
{ type:"reqi", ref:STR, contents:?BOOL }
where:
refis the reference string identifying the object sought.contentsis an optional boolean flag that, if true, indicates that any objects contained by the requested object (any objects in the entire containment hierarchy rooted at the object, in fact) should also be retrieved. If omitted it defaults to false.
← { to:"rep", op:"get", results:[OBJDESC], tag:?STR }
where:
resultsis an array of object descriptors, one for each object that was requested (directly or indirectly) in the originalgetmessage.tagechoes the tag from thegetrequest, if there was one, or will be omitted if the originalgetalso omitted it.
{ type:"obji", ref:STR, obj:?OBJ, failure:?STR }
where:
refis the reference string identifying the object.objis representation of the state of the object. The details of this will, of course, vary depending upon what kind of object it is. This will be absent if the object could not be retrieved.failureis an error message string indicating the reason why the Repository was unable retrieve the object. This will only appear in failure cases.
put
→ { to:"rep", op:"put", what:[OBJDESC], tag:?STR }
This message requests the Repository to store the new persistent state of one or more objects.
whatis an array of object descriptors containing the states of the objects that are to be stored. These object descriptors take the form documented above in the description of thegetrequest.tagis an optional tag string that, if given, will be sent back with the response(s), to help the client match up requests and responses.
put request. That is, the persistent states of all specified
objects are updated or none are.
Note that there is no explicit "create" operation. Simply issue
a put for an object not currently stored.
The Repository will reply with a message of the form:
← { to:"rep", op:"put", results:[RESULTDESC], tag:?STR }
where:
resultsis an array of result descriptors, one for each object whose storage was requested in the originalputmessage.tagechoes the tag from theputrequest, if there was one, or will be omitted if the originalputalso omitted it.
{ type:"stati", ref:STR, failure:?STR }
where:
refis a reference string identifying the object the result pertains to.failureis an error message string indicating the reason why the Repository was unable store the object. This will only appear in failure cases.
remove
→ { to:"rep", op:"remove", refs:[STR], tag:?STR }
This message requests the Repository to delete the persistent state of one or more objects.
refsis an array of object reference strings identifying the objects to be deleted.tagis an optional tag string that, if given, will be sent back with the response(s), to help the client match up requests and responses.
← { to:"rep", op:"remove", results:[RESULTDESC], tag:?STR }
where:
resultsis an array of result descriptors, one for each object whose deletion was requested in the originalputmessage. These result descriptors take the form documented above in the description of theputrequest.tagechoes the tag from theputrequest, if there was one, or will be omitted if the originalputalso omitted it.
Admin Protocol
The Repository admin protocol is used to administer the Repository server.
reinit
→ { to:"admin", op:"reinit" }
This message instructs the Repository to reinitialize itself.
shutdown
→ { to:"admin", op:"shutdown" kill:?BOOL }
This message instructs the Repository to shut itself down.
where:
killis an optional flag that if true orders an abrupt termination of the server. Normally, a server will empty its message queues, checkpoint any active state, and perform an orderly shutdown. However, if thekillflag is true, it will exit immediately without stopping to clean things up. The value defaults to false if the parameter is omitted.
