Skip to main content

CLI tool leveraging Redis locking pattern for management of distributed applications in cloud

Project description

lockr python3.8 python3.9 python3.10 buildPassing

LockR is an open source CLI tool which solves the problem of concurrency management for distributed applications in cloud, using Redis.

In summary, it provides out of the box ability to use the well known Redis Locking pattern or Redlock Algorithm

Read more here

Why LockR?

  • Manage any application in the cloud:
    • It is meant to be a very general purpose CLI tool, to provide applications with distributed locking mechanism, to prevent duplicate instances of the application running at the same time

    • Usable for all sorts of applications (Flask app, Spring boot app, Celery workers etc.) if you want to prevent more than one instance of the app running at the same time.

  • Extremely fault-tolerant:
    • LockR is designed to be resilient to network errors, application problems and so on. So you only need to worry about your own application.

  • Simple to use:
    • LockR is very straightforward to use and maintain

  • No 3rd party dependencies:
    • LockR has been built entirely using in-built python libraries, not relying on any 3rd party libraries.

Getting started

Install with pip

pip install lockr

You then need a configuration file to tell lockr what to do. Its usually called lockr.ini but can be any name also be anywhere, as long as it is readable and in the right format.

To find usage instructions run:

lockr --help
lockr run --help

A general configuration looks as follows:

# LockR default configuration file
[lockr]
# LockR timeout in milliseconds. Higher values mean it will take longer before a
# downed node is recognized, lower values mean more Redis traffic.
timeout = 1000
# defaults to 1000

# Name of the lock. If empty, generated from the command. Defaults to 'lockr'
lockname = test-lockr

# Command to execute. This is the process you want to start up. MUST BE SPECIFIED
# Examples are: Flask app, celery worker , anything which you don't want to run on more than one node at a time
command = "echo 'test lockr'"


# Whether or not to run command in shell. Defaults to 'no'
use_shell = no

# Specify any custom lock prefix for the lock value stored in key 'lockname'
# Defaults to 'LockR'. Accepts environment variables as well
lock_prefix = test-prefix

[redis]
# defaults to localhost. Specify environment variable or pass directly as well. Conflicts with 'cluster_nodes' (only one can be specified).
host = ${REDIS_HOST}

# Specify all the cluster nodes each in new line. Conflicts with 'host' (only one can be specified).
# Currently only works with environment variables
# The nodes must have cluster mode enabled
cluster_nodes = ${REDIS_HOST}:${REDIS_HOST}

# port is optional and defaults to 6379. Specify environment variable or pass directly as well
port = ${REDIS_HOST}

# In single Redis server mode only, you can SELECT the database. Defaults to 0. Ignored for cluster_nodes
database = 1

All the default parameters are optional, which take the default value if nothing is specified. It is recommended not to update them, unless you want to fine tune your lockr instance.

Then just run:

lockr run --dry-run

If your config file is valid, you should see the output:

Valid configuration found. Dry run verification successful

Once, you’ve confirmed the file is valid, run:

lockr run

Development

LockR is available on GitHub

Once you have the source you can run the tests with the following commands

pip install -r requirements.dev.txt
pytest tests/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lockr-0.0.7.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

lockr-0.0.7-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file lockr-0.0.7.tar.gz.

File metadata

  • Download URL: lockr-0.0.7.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.5

File hashes

Hashes for lockr-0.0.7.tar.gz
Algorithm Hash digest
SHA256 08bc5aee17beb298b3452a92bbee77a4237d049776366257b19ccfb4b91a425a
MD5 570dfcb033a83339ae58ac589a177dd9
BLAKE2b-256 cb1c31e2db8fb37c807faa5f5db975b6685de492650f4f3d1a55affbff066b23

See more details on using hashes here.

File details

Details for the file lockr-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: lockr-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.5

File hashes

Hashes for lockr-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4c39b9d7b372cf8b17ff26687df79b310a94cede78710339569b3eb89a997dae
MD5 1a97468dab8b47fc0bccdb069db5e7db
BLAKE2b-256 6ea6d7d35308172ef645340ea4c9f0b7b196da8e52f47baa98c6c3f446eae75e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page