This document describes the C-Service API.
Reminder and context
C-Service has vocation to be run in every part of the Concordant hierarchy i.e., C-Term, C-PoP and C-Cloud. It should then be runnable everywhere has a stand alone process but also inside browsers (as a service worker), this is why it is written in typescript.
Since it will be included everywhere it should be lightweight and then embedded only features that are necessary everywhere. It will act has a proxy between the different parts of the Concordant echo system.
Communication with a C-Client
The C-Service is made to run on top of any persistent key/value JSON document storage. For now we are using PouchDB and CouchDB.
The C-Service may be in charge of multiple applications, each application having its own database.
The C-Client library included into user device applications communicates with the C-Service has an entry point to the Concordant platform.
Object type manipulated by the API
The interface manipulates Strings representing JSON documents containing the state of CRDTs.
Queries
Gets all object of a given application:
appObjects(appName: String): [String]
Gets the object associated with given id in the given application:
appObject(appName: String, id: ID!): String
Mutators
Creates an application database with the given name:
createApp(appName: String): String
Deletes the given application database:
deleteApp(appName: String): String
Updates a given object with a new state, if there is one handle conflict:
updateObject(appName: String, id: ID!, document: String): String
Communication with other C-Service
This part of the API is used to ensure the link between different instances of C-Service.
Object type manipulated by the API
The interface manipulates Replicator which are objects storing information about links that have been registers between different databases. This objects are stored in a special database named "_replicators".
Replicator {
id: ID!
source: String
target: String
continuous: Boolean
state: String
}
Queries
Gets all replicators registered in the C-Service:
replicators: [Replicator]
Get the replicator associated to the given id:
replicator(id: ID!): String
Mutators
Registers a new replicator:
replicator(source: String, target: String, continuous: Boolean): Replicator
Technical details
The C-Service is an express http server listening by default on the port 4000.
The interface is defined with GraphQL using AppolloServer. This interface is exposed as REST API using Sofa on the path "/api".
All methods can be queried using http requests. Queries (respectively mutators) should be called with a request of type GET (respectively POST).