Giter Club home page Giter Club logo

gorilla's Introduction

Gorilla Logo

Gorilla

A Distributed Lock Service, Set up in Minutes.

Gorilla is a distributed lock service that allows multiple processes or nodes to coordinate and synchronize access to a shared resource or data.

Getting Started

To install dependencies.

$ make deps

To create and migrate your database.

$ make migrate

To start the application.

$ cp .env.example .env.local
$ export $(cat .env | xargs)

$ make run

Now you can visit localhost:4000 from your browser.

To run test cases:

$ make ci

To list all commands:

$ make

To run postgresql with docker

$ docker run -itd \
    -e POSTGRES_USER=gorilla \
    -e POSTGRES_PASSWORD=gorilla \
    -e POSTGRES_DB=gorilla_dev \
    -p 5432:5432 \
    --name postgresql \
    postgres:15.2

$ podman run -itd \
    -e POSTGRES_USER=brangus \
    -e POSTGRES_PASSWORD=brangus \
    -e POSTGRES_DB=brangus_dev \
    -p 5432:5432 \
    --name postgresql \
    postgres:15.2

# https://github.com/dbcli/pgcli
$ psql -h 127.0.0.1 -U brangus -d brangus_dev -W

Service Endpoints

  • Acquire Lock: Acquire a lock for a specific resource.
Endpoint:
    POST /api/v1/locks/{resource}

Request Body:
    {
        "owner": "<unique identifier for the requester>",
        "timeout": "<maximum time (in seconds) the lock can be held>",
        "metadata": "<any additional metadata for the lock>"
    }

Response:
    HTTP/1.1 200 OK
    {
        "id": <The lock ID>,
        "owner": "<The lock owner>",
        "resource": "<The lock resource name>",
        "token": "<A new unique token for the extended lock>",
        "timeout": <Actual time (in seconds) the lock can be held>,
        "metadata": ["list", "of", "metadata"],
        "createdAt": "2023-03-14T18:35:04",
        "updatedAt": "2023-03-14T18:35:04",
        "expireAt": "2023-03-14T19:35:04"
    }

Possible errors:
    HTTP/1.1 409 Conflict: The lock is already held by another owner.
    HTTP/1.1 400 Bad Request: The request is invalid or missing required parameters.
  • Release Lock: Release a lock for a specific resource.
Endpoint:
    DELETE /api/v1/locks/{resource}/{token}

Response:
    HTTP/1.1 204 No Content

Possible errors:
    HTTP/1.1 404 Not Found: The token is not associated with any lock for the resource.
  • Check Lock Status: Get the status of a lock for a specific resource.
Endpoint:
    GET /api/v1/locks/{resource}/{token}

Response:
    HTTP/1.1 200 OK
    {
        "id": <The lock ID>,
        "owner": "<The lock owner>",
        "resource": "<The lock resource name>",
        "token": "<A new unique token for the extended lock>",
        "timeout": <Actual time (in seconds) the lock can be held>,
        "metadata": ["list", "of", "metadata"],
        "createdAt": "2023-03-14T18:35:04",
        "updatedAt": "2023-03-14T18:35:04",
        "expireAt": "2023-03-14T19:35:04"
    }

Possible errors:
    HTTP/1.1 404 Not Found: The token is not associated with any lock for the resource.
  • Extend Lock Time: Extend the time a lock is held for a specific resource.
Endpoint:
    PUT /api/v1/locks/{resource}/{token}

Request Body:
    {
        "timeout": <maximum time (in seconds) the lock can be held>
    }

Response:
    HTTP/1.1 200 OK
    {
        "id": <The lock ID>,
        "owner": "<The lock owner>",
        "resource": "<The lock resource name>",
        "token": "<A new unique token for the extended lock>",
        "timeout": <Actual time (in seconds) the lock can be held>,
        "metadata": ["list", "of", "metadata"],
        "createdAt": "2023-03-14T18:35:04",
        "updatedAt": "2023-03-14T18:35:04",
        "expireAt": "2023-03-14T19:35:04"
    }

Possible errors:
    HTTP/1.1 404 Not Found: The token is not associated with any lock for the resource.
    HTTP/1.1 409 Conflict: The lock is already held by another owner or the extended timeout is less than the remaining time of the lock.

Versioning

For transparency into our release cycle and in striving to maintain backward compatibility, Gorilla is maintained under the Semantic Versioning guidelines and release process is predictable and business-friendly.

See the Releases section of our GitHub project for changelogs for each release version of Gorilla. It contains summaries of the most noteworthy changes made in each release. Also see the Milestones section for the future roadmap.

Bug tracker

If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clevenio/gorilla/issues

Security Issues

If you discover a security vulnerability within Gorilla, please send an email to [email protected]

Contributing

We are an open source, community-driven project so please feel free to join us. see the contributing guidelines for more details.

License

© 2023, Clivern. Released under MIT License.

Gorilla is authored and maintained by @clivern.

gorilla's People

Contributors

clivern avatar renovate[bot] avatar stack-file[bot] avatar

Stargazers

Ben Damman avatar Niranjan Anandkumar avatar Hannes Stöven avatar Felipe Menegazzi avatar  avatar Aaron Junod avatar Viktor Svub avatar Ian Smith avatar

Watchers

 avatar

Forkers

juanfer2

gorilla's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • actions/checkout v4
  • erlef/setup-beam v1
mix
mix.exs
  • phoenix ~> 1.6.13
  • phoenix_ecto ~> 4.4
  • ecto_sql ~> 3.6
  • ecto_sqlite3 >= 0.0.0
  • postgrex >= 0.0.0
  • phoenix_html ~> 3.0
  • phoenix_live_reload ~> 1.2
  • phoenix_live_view ~> 0.17.5
  • floki >= 0.30.0
  • phoenix_live_dashboard ~> 0.6
  • esbuild ~> 0.8
  • swoosh ~> 1.3
  • telemetry_metrics ~> 0.6
  • telemetry_poller ~> 1.0
  • gettext ~> 0.24
  • jason ~> 1.4
  • plug_cowboy ~> 2.5

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.