locking-service

December 8, 2024 ยท View on GitHub

taskfile pre-commit renovate NestJS TypeScript

locking-service

REST API service built with NestJS that provides distributed locking capabilities using Redis as backend.

User Story

As an automation engineer, I need a locking service API to:

  • Create locks with configurable TTL using timestring format (e.g. "5m", "1h")
  • List active locks and their status
  • Auto-expiration
  • Owner validation for lock operations

So that I can coordinate access to shared resources across distributed systems.

Installation

pnpm install

Configuration

You can pass CONFIG_PATH env variable to point to your configuration.yaml. Default path is $(XDG_CONFIG_HOME)/locking-service/configuration.yaml

You can use env variables as placeholder in the configuration.yaml

---
app:
  port: 3000
  host: 0.0.0.0

redis:
  host: ${env.REDIS_HOST}
  port: 6379
  keyPrefix: locking-service.
  # sentinels:
  #   - host: ${env.REDIS_HOST}
  #     port: 26379
  # name: redis-master

Running the app

# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod

Test

# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov

Lint

# run eslint
$ pnpm run lint