Introducing Lock State Service (LSS)
Managing asynchronous workflows, deployment pipelines, or system-level processes often requires coordination mechanisms to prevent conflicts or race conditions. Enter Lock State Service (LSS) — a lightweight, API-first solution for managing locks effortlessly.
Introducing Lock State Service (LSS)
With LSS, you can create, check, and modify locks using simple API calls. Whether you’re working with GitHub Actions, CRON jobs, or custom scripts, LSS offers a straightforward way to ensure process synchronization.
Why LSS?
Some common use cases include:
- [*] GitHub Actions Pipelines
Prevent QA branch deployments during E2E tests by locking processes until the tests are complete. - [*] System CRON Jobs
Ensure a job doesn’t start if another critical process is running. - [*] Ad-Hoc Locking for System Operations
Usecurl
to block the execution flow when necessary conditions aren’t met.
And best of all, LSS is free to use for low workloads, making it ideal for personal projects, small teams, and lightweight systems.
How It Works
Create a Lock
To create a new lock:
HTTP POST https://lock-states.deno.dev/locks
Optional URL Parameters:
l=true|1|T
— Initialize the lock in a locked state.e=ttl_in_seconds
— Set a Time-To-Live (TTL) for the lock.k=custom_auth_key
— Use a custom authorization key.
Response:
Example: Create a locked state with a 60-second TTL:
Check Lock State
To check a lock’s status:
HTTP GET https://lock-states.deno.dev/locks/:lockId
Responses:
204
— Unlocked423
— Locked404
— Lock not found
Example:
Lock or Unlock a Lock
Lock a Lock
HTTP PATCH https://lock-states.deno.dev/locks/:lockId/lock
Parameters:
k=lockKey
— Required for authentication.e=ttl_in_seconds
— Optional TTL.
Example: Lock forever:
Unlock a Lock
HTTP PATCH https://lock-states.deno.dev/locks/:lockId/unlock
Example: Unlock the lock:
Real-World Use Cases
Pipeline Synchronization
In my deployment pipeline, I have an asynchronous task running on a cluster. The next step in the pipeline waits for this task to complete by checking the lock status. Once the lock is released, the pipeline resumes seamlessly.
QA Environment Protection
When the QA team is running tests, they lock the QA environment. This prevents automated redeployments. A simple “resolve state lock” step in the pipeline ensures everything stays coordinated.
Try LSS Today!
LSS is designed to make lock management simple, effective, and accessible. With just a few API calls, you can avoid common workflow issues and ensure smooth operations across your systems.
Get started for free at LSS! 🚀