SubmitSD is a proof of concept service discovery service/server.
It is still under development and not feature complete.
Before you do anything, always run the following command to generate all the necessary code used in the project.
$ make generate
Running make
will generated all the necessary code and build Linux and Windows binaries and place them under the builds
directory.
$ make
Running the service while devloping can be done with make
$ make run
To change the address or mode pass in the updated variables
variables | OPTIONS |
---|---|
MODE | release/debug |
ADDR | address:port |
Example:
$ make ADDR=localhost:8000 run
Execute the binary which will start listening on address localhost:8081
. Use -h
for help.
$ cd builds
$ ./submitSD server
[GIN-debug] Listening and serving HTTP on localhost:8081
Once the server is running and accepting client connections, you can naviate to the address above in a browser or any other HTTP method.
Accessing the service via a browser will take you to the playground where you can start playing with the API.
Please note that this is still in early development and below is a list of features that I would like to still implement.
- Add services
- Renew services TTL
- Auto expiry of services
- GraphQL and served up via HTTP router
- Pubsub events via subscriptions
- Auto expiry and cleanups
- Backend store should periodically clean up expired services
- Backend store should take clean up callbacks and publish cleaned/expired services
- Issue with CTRL-C and stopping the cleanup and store properly - BUG
- Issue with the service passed to the callback it is not passing the correct service removed, it is some old reference - BUG
- Service queries by
- type
- name
- version
- etc....
- Indexing for fast lookups and queries
- Persistance (optional)
- gRPC service
- RestAPI
- Web based GUI with realtime updates
- Extend the message to include service config
- Add Update API calls to updated services
- Proper tests ...more to come
Query:
mutation create {
create(
input: {id: "server", name: "submitSD", description: "graphQL server", version: "v0.0.0", address: "localhost:8081", ttl: "1m"}
) {
id
created_at
name
description
address
ttl
expires_at
}
}
Response:
{
"data": {
"create": {
"id": "server",
"created_at": "2022-10-06T00:11:31.628603+11:00",
"name": "submitSD",
"description": "graphQL server",
"address": "localhost:8081",
"ttl": "1m",
"expires_at": "2022-10-06T00:12:31.628606+11:00"
}
}
}
Query:
mutation renew {
renew(input: {id: "server", ttl: "1m"}) {
id
created_at
name
description
address
ttl
expires_at
}
}
Response:
{
"data": {
"renew": {
"id": "server",
"created_at": "2022-10-06T00:15:25.217102+11:00",
"name": "submitSD",
"description": "graphQL server",
"address": "localhost:8081",
"ttl": "1m0s",
"expires_at": "2022-10-06T00:16:35.567788+11:00"
}
}
}
Query:
query all {
services {
id
created_at
name
description
address
ttl
expires_at
}
}
Response:
{
"data": {
"services": [
{
"id": "server",
"created_at": "2022-10-06T00:13:34.830831+11:00",
"name": "submitSD",
"description": "graphQL server",
"address": "localhost:8081",
"ttl": "1m",
"expires_at": "2022-10-06T00:14:34.830832+11:00"
}
]
}
}
Query:
subscription pubsub {
events {
timestamp
event
service {
name
}
}
}
Response:
{
"data": {
"events": {
"timestamp": "2022-10-10T22:53:37.908826+11:00",
"event": "RENEWED",
"service": {
"name": "submitSD"
}
}
}
}