{"id":19226292,"url":"https://github.com/qonto/activejob-lockable","last_synced_at":"2025-09-01T12:11:31.496Z","repository":{"id":51611092,"uuid":"109848783","full_name":"qonto/activejob-lockable","owner":"qonto","description":"Gem to make jobs lockable","archived":false,"fork":false,"pushed_at":"2023-06-06T08:55:51.000Z","size":23,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-23T18:08:52.769Z","etag":null,"topics":["activejob","lockable","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qonto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-07T14:47:57.000Z","updated_at":"2025-01-02T05:03:00.000Z","dependencies_parsed_at":"2025-04-21T12:46:52.788Z","dependency_job_id":null,"html_url":"https://github.com/qonto/activejob-lockable","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/qonto/activejob-lockable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qonto%2Factivejob-lockable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qonto%2Factivejob-lockable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qonto%2Factivejob-lockable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qonto%2Factivejob-lockable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qonto","download_url":"https://codeload.github.com/qonto/activejob-lockable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qonto%2Factivejob-lockable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273122129,"owners_count":25049539,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activejob","lockable","rails","ruby"],"created_at":"2024-11-09T15:18:07.889Z","updated_at":"2025-09-01T12:11:31.447Z","avatar_url":"https://github.com/qonto.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Gem Version](https://badge.fury.io/rb/activejob-lockable.svg) ![CI Status](https://github.com/qonto/activejob-lockable/actions/workflows/tests.yml/badge.svg)\n\n# ActiveJob::Lockable\n\nGem to make to make jobs lockable. Useful when a job is called N times, but only a single execution is needed.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'activejob-lockable'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install activejob-lockable\n\n## Configuration\n\nCreate an initializer with redis connection:\n\n```ruby\nActiveJob::Lockable.redis = Redis.current # if you have a redis instance\n\n# or\nActiveJob::Lockable.redis = 'redis://localhost:6379/0'\n# or\nActiveJob::Lockable.redis = {\n  host: '10.0.1.1',\n  port: 6380,\n  db: 15\n}\n```\n\n## Usage\n\n```ruby\n# job\n# nothing to change!\n```\n```ruby\n# code\nMyJob.set(lock: 10.seconds).perform_later(id)\n```\n\nNow, after the first enqueue (perform_later), a lock will be created and the following enqueues within 10 seconds will be rejected.\n\n### Lock key\n\nA lock key by default:\n\n`job_name_in_downcase:md5(arguments)`\n\nTo override the key you can override method `lock_key`:\n\n```ruby\n# job\ndef lock_key\n  'my-custom-key'\nend\n```\n\n### Lock period\n\nYou can set a fixed `lock_period`, in that case `.set(lock: N)` will be ignored and the job will always be lockable:\n\n```ruby\n# job\ndef lock_period\n  1.day\nend\n```\n\n### On lock action\n\nWhen a job is locked and another one is enqueued, you can set up a custom callback that will be called. This is useful if you want to raise exception or be notified:\n\n```ruby\n# job\nclass MyJob \u003c ApplicationJob\n  on_locked :raise_if_locked\n\n  def raise_if_locked\n    raise 'Job is locked'\n  end\nend\n```\n\n## Dependencies\n\n* [ActiveSupport](https://github.com/rails/rails/tree/master/activesupport)\n* [ActibeJob](https://github.com/rails/rails/tree/master/activejob)\n* [Redis](https://redis.io/)\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [qonto/activejob-lockable](https://github.com/qonto/activejob-lockable). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Releasing\n\nTo publish a new version to rubygems, update the version in `lib/activejob/lockable/version.rb`, and merge.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqonto%2Factivejob-lockable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqonto%2Factivejob-lockable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqonto%2Factivejob-lockable/lists"}