{"id":18656586,"url":"https://github.com/zendesk/resque-disable-job","last_synced_at":"2025-04-11T18:30:55.835Z","repository":{"id":49180271,"uuid":"109863970","full_name":"zendesk/resque-disable-job","owner":"zendesk","description":"Resque Disable Job Plugin","archived":false,"fork":false,"pushed_at":"2025-01-20T12:38:14.000Z","size":142,"stargazers_count":3,"open_issues_count":4,"forks_count":2,"subscribers_count":308,"default_branch":"main","last_synced_at":"2025-03-25T16:51:41.003Z","etag":null,"topics":["resque","resque-plugin"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zendesk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2017-11-07T16:47:13.000Z","updated_at":"2025-01-20T12:38:14.000Z","dependencies_parsed_at":"2022-08-21T00:20:40.269Z","dependency_job_id":"f67280df-16cc-4061-8123-2ced5abe1370","html_url":"https://github.com/zendesk/resque-disable-job","commit_stats":{"total_commits":33,"total_committers":3,"mean_commits":11.0,"dds":0.09090909090909094,"last_synced_commit":"b97f58f5ca6fe1fa8b7a50d36211687b1cdb8f10"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fresque-disable-job","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fresque-disable-job/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fresque-disable-job/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fresque-disable-job/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/resque-disable-job/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248458369,"owners_count":21107064,"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","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":["resque","resque-plugin"],"created_at":"2024-11-07T07:24:10.854Z","updated_at":"2025-04-11T18:30:55.819Z","avatar_url":"https://github.com/zendesk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Resque::Disable::Job\n\n[![Build Status](https://travis-ci.org/zendesk/resque-disable-job.svg?branch=master)](https://travis-ci.org/zendesk/resque-disable-job)\n\n\nThis is a Resque plugin that allows us to disable jobs from being processed, by using the job class name and arguments.\nIt uses some Redis data structures to keep a record of what jobs need to be disabled and how many jobs were disabled for that rule.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'resque-disable-job'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install resque-disable-job\n\n## Usage\n\n### Job\nYou can add it to your job like any other Resque plugin:\n\n```ruby\n  class TestJob\n    extend Resque::Plugins::DisableJob\n    @queue = :test\n\n    def self.perform(some_id, other_id)\n    end\n  end\n```\nThe plugin will add the `before_perform_allow_disable_job` Resque hook. This will check if the current job needs to be stopped and it calls the `disable_job_handler` method.\nBy default this will just raise `Resque::Job::DontPerform`. If you want to do more you can override it in your job or base class.\n\n### Disabling a Job\n\nIn your application's console you can use the `Resque::Plugins::DisableJob::Job.disable_job` method to disable a job.\n\n`Resque::Plugins::DisableJob::Job.disable_job(job_name, matching_arguments, ttl = 3600)`\n\nNote: By default, each rule has a ttl of 1 hour. This is because disabling a job should be a temporary action.\n\n```ruby\n# Disable all the jobs of that class:\nTestJob.disable\n# Disable all TestJob jobs with the first argument `65` \nTestJob.disable([65])\n# Disable all SampleJob jobs that have the argument a == 5\nSampleJob.disable({a: 5})\n\n# Disable a job for one hour\nSampleJob.disable({a: 1}, 3600)\n\n# Re-enable jobs:\nTestJob.enable()\nTestJob.enable([65])\n\n# Simple kill-switch to remove all the rules for the job\nTestJob.enable_all\n\n# Kill-switch to remove all the jobs and their rules\nResque::Plugins::DisableJob::Job.enable_all!\n```\n\n**Note**: You can disable many arguments for one job type, but for performance reasons we look at only 10 rules.\n\n### Operations\n\n`Resque::Plugins::DisableJob::Stats` comes with a a few methods that will help you keep track of actively disabled jobs and how many times the rule was matched. \nThey all return an `Array[Resque::Plugins::DisableJob::Rule]`.\n\n* `all_disabled_jobs` - a list of all the disabled jobs and their rules\n* `job_disabled_rules(job_name)` - a list of all the rules for one particular job \n* `disabled_stats` - all the disabled jobs, their rules, and the counter of how many times it was matched (the `Rule` objects have the `counter` attribute set)  \n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/zendesk/resque-disable-job. 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## Code of Conduct\n\nEveryone interacting in the Resque::Disable::Job project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/zendesk/resque-disable-job/blob/master/CODE_OF_CONDUCT.md).\n\n## Copyright and license\n\nCopyright 2017 Zendesk, Inc.\n\nLicensed under the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0) (the \"License\"); you may not use this file except in compliance with the License.\n\nYou may obtain a copy of the License at\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fresque-disable-job","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Fresque-disable-job","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fresque-disable-job/lists"}