Quick Start¶
1. Start the server¶
The server listens on 0.0.0.0:6388 by default. See Server Configuration for tuning options.
2. Acquire a lock¶
Using netcat (or any TCP client):
This sends a lock request for key my-key with a 10-second acquire timeout. On success, the server responds:
The token is a unique identifier for this lock hold, and 33 is the lease TTL in seconds.
3. Release a lock¶
Replace <token> with the token returned from step 2. The server responds:
4. Interactive session¶
For an interactive session, use netcat without piping:
Then type each line of the protocol manually:
The server responds with ok <token> <lease_ttl>. To release, type:
What happens under the hood¶
- The client opens a TCP connection to the server.
- It sends a lock request with the key and timeout.
- The server grants the lock immediately if it's free, or enqueues the client in FIFO order.
- Once acquired, the client is responsible for renewing the lease before it expires (using the
ncommand). - On release (or disconnect), the server frees the lock and grants it to the next FIFO waiter.
- Background goroutines handle lease expiry sweeps and garbage collection of idle lock state.