Start flux and Redis, register a service, discover it.
Prerequisites
Use the Public Image (no clone)
docker run -d --name redis redis:7-alpine
docker run -d --name flux --link redis -e REDIS_ADDR=redis:6379 -p 8080:8080 ghcr.io/xinnaider/flux
curl http://localhost:8080/health
Then jump to Register a Service.
Clone the Repository
git clone https://github.com/xinnaider/flux
cd flux
Start with Docker Compose
docker compose up -d
Check it’s alive:
curl http://localhost:8080/health
# {"status":"ok"}
Register a Service
curl -X POST http://localhost:8080/register \
-H "Content-Type: application/json" \
-d '{"name":"ms.auth","host":"10.0.0.5","port":3001,"health_url":"/health"}'
# {"instance_id":"10.0.0.5:3001","ttl_seconds":15}
Send a Heartbeat
curl -X POST http://localhost:8080/heartbeat \
-H "Content-Type: application/json" \
-d '{"name":"ms.auth","instance_id":"10.0.0.5:3001","active_connections":3}'
# {"ok":true,"ttl_seconds":15}
Discover & Redirect
curl -v http://localhost:8080/ms.auth/login
# HTTP/1.1 302 Found
# Location: http://10.0.0.5:3001/login
Run Locally (without Docker)
go run ./cmd/server
go build -o bin/flux ./cmd/server
./bin/flux