package main
import (
"github.com/GoCollaborate"
)
func main() {
collaborate.Run()
}Running GoCollaborate server in Coordinator mode is very simple, you just go:
go run main.go -mode=cdntThe restful services api is available at:
http://localhost:8080/services
{
"type": <ParamType>,
"description": <String>,
"constraints": [<Constraint>],
"required": <Bool>
}
{
"ip": <String>,
"port": <Int>,
"alive": <Bool>,
"api": <String>
}
| 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 |
| LBModeIPHash | 6 | Assign tasks based on the hash value of subscriber IP |
| Name | Value |
|---|---|
| ArgTypeInteger | "integer" |
| ArgTypeNumber | "number" |
| ArgTypeString | "string" |
| ArgTypeObject | "object" |
| ArgTypeBoolean | "boolean" |
| ArgTypeNull | "null" |
| ArgTypeArray | "array" |
{
"key": <ConstraintKey>,
"value": <Interface{}>
}
| 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" |
{
"cards": [<Card>]
}
{
"token": <String>
}
{
"card": <Card>
}
-
POST:
/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
- GET:
/services/{serviceid}
The service provider should register their endpoint as per they expose for external access.
-
POST:
/services/{serviceid}/registry -
Headers:
- Content-Type:
application/json
- Content-Type:
Body (required):
{
"data": [{
"id": <String/"">,
"type": "registry",
"attributes": <Registry>
}]
}
The service consumer should subscribe their interest as per they request for.
-
POST:
/services/{serviceid}/subscription -
Headers:
- Content-Type:
application/json
- Content-Type:
Body:
{
"data": [{
"id": <String/"">,
"type": "subscription",
"attributes": <Subscription>
}]
}
The service provider should deregister their endpoint as per they terminate the provision.
- DELETE:
/services/{serviceid}/registry/{ip}/{port}
- DELETE:
/services/{serviceid}/registry
The service consumer should unsubscribe their usage as per they terminate the dependencies.
- DELETE:
/services/{serviceid}/subscription/{token}
- DELETE:
/services/{serviceid}/subscription
Delete a service if it is no longer required.
- DELETE:
/services/{serviceid}
Send server heartbeats to Coordinator.
-
POST:
/services/heartbeat -
Headers:
- Content-Type:
application/json
- Content-Type:
Body:
{
"data": [{
"id": <String/"">,
"type": "subscription",
"attributes": <Heartbeat>
}]
}
Client launch request to call a service
- GET:
/query/{srvid}/{token}