Coordinator Restful JSON API
Before You Go
GoCollaborate provides a set of RESTful api exposure according to JSON API Specification where you can create, delete, register, subscribe and query services from various platforms and programming languages.
Extended Basic Types
Parameter
{
"type": <ParamType>,
"description": <String>,
"constraints": [<Constraint>],
"required": <Bool>
}
Card
{
"ip": <String>,
"port": <Int>,
"alive": <Bool>,
"api": <String>
}
Mode
Name | Value | Description |
---|---|---|
ClbtModeNormal | 0 | Working mode |
ClbtModeOnlyRegister | 1 | Collaborator only registers service, service is not accessible until it has been changed to ClbtModeNormal |
ClbtModeOnlySubscribe | 2 | Subscriber only subscribes to collaborator service at coordinator, no service redirection will be provided |
LBModeRandom | 3 | Assign tasks as per weighted probability |
LBModeLeastActive | 4 | Assign tasks to least active responders |
LBModeRoundRobin | 5 | Assign tasks sequentially based on the order of collaborator |
LBModeTokenHash | 6 | Assign tasks based on the hash value of subscriber token |
ParamType
Name | Value |
---|---|
ArgTypeInteger | "integer" |
ArgTypeNumber | "number" |
ArgTypeString | "string" |
ArgTypeObject | "object" |
ArgTypeBoolean | "boolean" |
ArgTypeNull | "null" |
ArgTypeArray | "array" |
Constraint
{
"key": <ConstraintKey>,
"value": <Interface{}>
}
ConstraintKey
Name | Value |
---|---|
ConstraintTypeMax | "maximum" |
ConstraintTypeMin | "minimum" |
ConstraintTypeXMin | "exclusiveMinimum" |
ConstraintTypeXMax | "exclusiveMaximum" |
ConstraintTypeUniqueItems | "uniqueItems" |
ConstraintTypeMaxProperties | "maxProperties" |
ConstraintTypeMinProperties | "minProperties" |
ConstraintTypeMaxLength | "maxLength" |
ConstraintTypeMinLength | "minLength" |
ConstraintTypePattern | "pattern" |
ConstraintTypeMaxItems | "maxItems" |
ConstraintTypeMinItems | "minItems" |
ConstraintTypeEnum | "enum" |
ConstraintTypeAllOf | "allOf" |
ConstraintTypeAnyOf | "anyOf" |
ConstraintTypeOneOf | "oneOf" |
Registry
{
"id": [String/optional],
"type":"registry",
"attributes": [Card]
}
Subscription
- POST:
/v1/services/{id}/subscription
{ "id": [String/optional], "type":"subscription", }
Heartbeat
- GET:
/v1/heartbeat
Cluster Heartbeat
- GET:
/v1/cluster/{id}/heartbeat
Create Service
POST:
/v1/services
Headers:
- Content-Type:
application/json
- Content-Type:
Body (required):
{
"data": [{
"type": "service",
"attributes": {
"description": <String>,
"parameters": [<Parameter>],
"registers": [<Card>],
"subscribers": [<String>],
"mode": <Mode>,
"load_balance_mode": <Mode>,
"dependencies": [<String>],
"version": <String>,
"platform_version": <String>
}
}]
}
Get Services
Bulk
- GET:
/v1/services
Single
- GET:
/v1/services/{serviceid}
Register Service
The service provider should register their endpoint as per they expose for external access.
POST:
/v1/services/{id}/registry
Headers:
- Content-Type:
application/json
- Content-Type:
POST:
/v1/services/{id}/registry
- Body(required)
{ "data": [{ "id": [String/optional], "type":"registry", "attributes": [Card] }] }
Subscribe Service
The service consumer should subscribe their interest as per they request for.
POST:
/v1/services/{id}/subscription
Headers:
- Content-Type:
application/json
- Content-Type:
Body:
{ "data": [{ "id": [String/optional], "type": "subscription", "attributes": <Subscription> }] }
Deregister Service
The service provider should deregister their endpoint as per they terminate the provision.
Single Deletion
- DELETE:
/v1/services/{serviceid}/registry/{ip}/{port}
Unsubscribe Service
The service consumer should unsubscribe their usage as per they terminate the dependencies.
Single Deletion
- DELETE:
/v1/services/{serviceid}/subscription/{token}
Delete Service
Delete a service if it is no longer required.
- DELETE:
/v1/services/{serviceid}
Heartbeat
Send server heartbeats to Coordinator for individuals.
GET:
/v1/services/heartbeat
Headers:
- Content-Type:
application/json
- Content-Type:
Cluster Heartbeat
Send server heartbeats to Coordinator for cluster.
GET:
/v1/cluster/{id}/heartbeat
Headers:
- Content-Type:
application/json
- Content-Type:
Query Service
Client launch request to call a service
- GET:
/v1/query/{srvid}/{token}