lockr


Namelockr JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/PaarthB/LockR/
SummaryCLI tool leveraging Redis locking pattern for management of distributed applications in cloud
upload_time2022-12-04 23:43:27
maintainer
docs_urlNone
authorPaarth Bhasin
requires_python>=3.8.13
licenseApache License, Version 2.0
keywords
VCS
bugtrack_url
requirements redis click requests fakeredis
Travis-CI
coveralls test coverage No coveralls.
            LockR
========

.. |logo| image:: https://raw.githubusercontent.com/PaarthB/LockR/main/assets/lockr-logo-1.png
    :alt: lockr
    :width: 35%

.. |py38| image:: https://img.shields.io/badge/python-3.8-blue.svg
    :alt: python3.8
    :width: 10%


.. |py39| image:: https://img.shields.io/badge/python-3.9-blue.svg
    :alt: python3.9
    :width: 10%


.. |py310| image:: https://img.shields.io/badge/python-3.10-blue.svg
    :alt: python3.10
    :width: 11%


.. |CI| image:: https://raw.githubusercontent.com/dwyl/repo-badges/main/svg/build-passing.svg
    :alt: buildPassing
    :width: 13%

.. |coverage| image:: https://img.shields.io/badge/coverage-90%25-lightgreen
    :alt: coverage
    :width: 13%

.. |stable| image:: https://img.shields.io/badge/latest-0.0.8-lightblue
    :alt: stable-release
    :width: 11%

|logo|
--------
|py38| |py39| |py310| |CI| |coverage| |stable|

``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 <https://redis.io/docs/reference/patterns/distributed-locks/>`_

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 beat/worker 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.

Setup
-----

- Redis Server:
    * You need an up and running redis server (or redis cluster), as later you need to specify the hostname and port for the Redis Server
    * **Minimum redis version**: `2.6.12`


Getting started
----------------


Install with ``pip``

.. code-block:: python

    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:

.. code-block:: console

    lockr --help
    lockr run --help

A general configuration looks as follows:

.. code-block:: python

    # 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_PORT}

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

    # 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:

.. code-block:: console

    lockr run --dry-run

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

.. code-block:: console

    Valid configuration found. Dry run verification successful

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

.. code-block:: console

    lockr run


Development
------------
``LockR`` is available on `GitHub <https://github.com/PaarthB/LockR>`_

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

.. code-block:: console

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





            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PaarthB/LockR/",
    "name": "lockr",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.13",
    "maintainer_email": "",
    "keywords": "",
    "author": "Paarth Bhasin",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/81/1d/ce2806e6cf1d28ff5567a526df2ad0f7e3ba1e250324a05aa7fe82ebf941/lockr-0.0.9.tar.gz",
    "platform": null,
    "description": "LockR\n========\n\n.. |logo| image:: https://raw.githubusercontent.com/PaarthB/LockR/main/assets/lockr-logo-1.png\n    :alt: lockr\n    :width: 35%\n\n.. |py38| image:: https://img.shields.io/badge/python-3.8-blue.svg\n    :alt: python3.8\n    :width: 10%\n\n\n.. |py39| image:: https://img.shields.io/badge/python-3.9-blue.svg\n    :alt: python3.9\n    :width: 10%\n\n\n.. |py310| image:: https://img.shields.io/badge/python-3.10-blue.svg\n    :alt: python3.10\n    :width: 11%\n\n\n.. |CI| image:: https://raw.githubusercontent.com/dwyl/repo-badges/main/svg/build-passing.svg\n    :alt: buildPassing\n    :width: 13%\n\n.. |coverage| image:: https://img.shields.io/badge/coverage-90%25-lightgreen\n    :alt: coverage\n    :width: 13%\n\n.. |stable| image:: https://img.shields.io/badge/latest-0.0.8-lightblue\n    :alt: stable-release\n    :width: 11%\n\n|logo|\n--------\n|py38| |py39| |py310| |CI| |coverage| |stable|\n\n``LockR`` is an open source CLI tool which solves the problem of concurrency management for distributed applications in cloud, using Redis.\n\nIn summary, it provides out of the box ability to use the well known **Redis Locking pattern** or **Redlock Algorithm**\n\nRead more `here <https://redis.io/docs/reference/patterns/distributed-locks/>`_\n\nWhy LockR?\n----------\n\n- Manage any application in the cloud: \n    *  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\n    * Usable for all sorts of applications (Flask app, Spring boot app, Celery beat/worker etc.) if you want to prevent more than one instance of the app running at the same time.\n- Extremely fault-tolerant: \n    * `LockR` is designed to be resilient to network errors, application problems and so on. So you only need to worry about your own application.\n- Simple to use: \n    * `LockR` is very straightforward to use and maintain\n- No 3rd party dependencies: \n    * `LockR` has been built entirely using in-built python libraries, not relying on any 3rd party libraries.\n\nSetup\n-----\n\n- Redis Server:\n    * You need an up and running redis server (or redis cluster), as later you need to specify the hostname and port for the Redis Server\n    * **Minimum redis version**: `2.6.12`\n\n\nGetting started\n----------------\n\n\nInstall with ``pip``\n\n.. code-block:: python\n\n    pip install lockr\n\nYou then need a configuration file to tell ``lockr`` what to do. Its usually called ``lockr.ini`` but can be any name also be anywhere,\nas long as it is readable and in the right format.\n\nTo find usage instructions run:\n\n.. code-block:: console\n\n    lockr --help\n    lockr run --help\n\nA general configuration looks as follows:\n\n.. code-block:: python\n\n    # LockR default configuration file\n    [lockr]\n    # LockR timeout in milliseconds. Higher values mean it will take longer before a\n    # downed node is recognized, lower values mean more Redis traffic.\n    timeout = 1000\n    # defaults to 1000\n\n    # Name of the lock. If empty, generated from the command. Defaults to 'lockr'\n    lockname = test-lockr\n\n    # Command to execute. This is the process you want to start up. MUST BE SPECIFIED\n    # Examples are: Flask app, celery worker , anything which you don't want to run on more than one node at a time\n    command = \"echo 'test lockr'\"\n\n\n    # Whether or not to run command in shell. Defaults to 'no'\n    use_shell = no\n\n    # Specify any custom lock prefix for the lock value stored in key 'lockname'\n    # Defaults to 'LockR'. Accepts environment variables as well\n    lock_prefix = test-prefix\n\n    [redis]\n    # defaults to localhost. Specify environment variable or pass directly as well. Conflicts with 'cluster_nodes' (only one can be specified).\n    host = ${REDIS_HOST}\n\n    # Specify all the cluster nodes each in new line. Conflicts with 'host' (only one can be specified).\n    # Currently only works with environment variables\n    # The nodes must have cluster mode enabled\n    cluster_nodes = ${REDIS_HOST}:${REDIS_PORT}\n\n    # port is optional and defaults to 6379. Specify environment variable or pass directly as well\n    port = ${REDIS_PORT}\n\n    # In single Redis server mode only, you can SELECT the database. Defaults to 0. Ignored for cluster_nodes\n    database = 1\n\nAll the default parameters are optional, which take the default value if nothing is specified. It is recommended not to update them,\nunless you want to fine tune your `lockr` instance.\n\nThen just run:\n\n.. code-block:: console\n\n    lockr run --dry-run\n\nIf your config file is valid, you should see the output:\n\n.. code-block:: console\n\n    Valid configuration found. Dry run verification successful\n\nOnce, you've confirmed the file is valid, run:\n\n.. code-block:: console\n\n    lockr run\n\n\nDevelopment\n------------\n``LockR`` is available on `GitHub <https://github.com/PaarthB/LockR>`_\n\nOnce you have the source you can run the tests with the following commands\n\n.. code-block:: console\n\n    pip install -r requirements.dev.txt\n    pytest tests/\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "CLI tool leveraging Redis locking pattern for management of distributed applications in cloud",
    "version": "0.0.9",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "6dc992d76b7ff52d34e9c9e75e382539",
                "sha256": "0480f84d487390c4fe18d68c7925ad28886d9b3e070e476dbb70659da029f1e6"
            },
            "downloads": -1,
            "filename": "lockr-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6dc992d76b7ff52d34e9c9e75e382539",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.13",
            "size": 9724,
            "upload_time": "2022-12-04T23:43:25",
            "upload_time_iso_8601": "2022-12-04T23:43:25.043766Z",
            "url": "https://files.pythonhosted.org/packages/1c/e7/99ab3cf8043a771f2ca00fc0e2153331602913c2925dfd31247dda515ccb/lockr-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "26fe7f5926f05bfcb3a82bb2598bb28f",
                "sha256": "0b37103ef6efb3160eea113f3188ebb785670a14b31ebd93d5440a04130244b1"
            },
            "downloads": -1,
            "filename": "lockr-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "26fe7f5926f05bfcb3a82bb2598bb28f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.13",
            "size": 33346,
            "upload_time": "2022-12-04T23:43:27",
            "upload_time_iso_8601": "2022-12-04T23:43:27.693349Z",
            "url": "https://files.pythonhosted.org/packages/81/1d/ce2806e6cf1d28ff5567a526df2ad0f7e3ba1e250324a05aa7fe82ebf941/lockr-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-04 23:43:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "PaarthB",
    "github_project": "LockR",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "redis",
            "specs": [
                [
                    "==",
                    "4.3.1"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.2"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.27.1"
                ]
            ]
        },
        {
            "name": "fakeredis",
            "specs": [
                [
                    "==",
                    "1.8"
                ]
            ]
        }
    ],
    "lcname": "lockr"
}
        
Elapsed time: 0.01708s