https://github.com/samdvr/heartbeat
Service Discovery Server
https://github.com/samdvr/heartbeat
Last synced: 8 months ago
JSON representation
Service Discovery Server
- Host: GitHub
- URL: https://github.com/samdvr/heartbeat
- Owner: samdvr
- Created: 2018-01-11T04:15:44.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-11T15:40:17.000Z (over 8 years ago)
- Last Synced: 2025-02-03T08:01:41.307Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Heartbeat
## Disclaimer
This project is a basic prototype for more battle tested service discovery libraries, checkout
[consul](https://github.com/hashicorp/consul) or [eureka](https://github.com/Netflix/eureka)
## Creating a heartbeat
Nodes should hit this endpoint every 30 seconds to be considered healthy. If a node misses 2 heartbeats (60 seconds), it will get evicted from service's healthy node list.
### POST /heartbeat
Parameters
service | string | required | Service name of this node.
ip | string | required | IP Address of this node.
timestamp | string | required | Epoch timestamp of the heartbeat.
Example:
#### Request
```
curl -X POST \
http://localhost:8080/heartbeat \
-d 'ip=127.0.0.1&service=user×tamp=1515683663'
```
#### Response
```
Status: 201
{}
```
## Getting a healthy node for a service
### GET /service/:name
Returns a healthy node's ip address for a given service.
#### Request
```
curl -X GET http://localhost:8080/service/sam
```
#### Response
```
{"ip":"127.0.0.1"}
```