{"id":27390187,"url":"https://github.com/sailor/quiq","last_synced_at":"2025-04-13T19:39:20.833Z","repository":{"id":39683724,"uuid":"236580742","full_name":"sailor/quiq","owner":"sailor","description":"Distributed task queue written in Ruby, backed by Redis and using event loops to handle concurrency","archived":false,"fork":false,"pushed_at":"2022-12-14T09:43:28.000Z","size":2293,"stargazers_count":32,"open_issues_count":11,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-06T12:40:53.814Z","etag":null,"topics":["activejob","async","background-jobs","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/sailor.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}},"created_at":"2020-01-27T19:56:57.000Z","updated_at":"2023-09-08T18:02:45.000Z","dependencies_parsed_at":"2023-01-28T21:00:36.328Z","dependency_job_id":null,"html_url":"https://github.com/sailor/quiq","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sailor%2Fquiq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sailor%2Fquiq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sailor%2Fquiq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sailor%2Fquiq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sailor","download_url":"https://codeload.github.com/sailor/quiq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248769802,"owners_count":21158865,"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":["activejob","async","background-jobs","ruby"],"created_at":"2025-04-13T19:39:20.284Z","updated_at":"2025-04-13T19:39:20.817Z","avatar_url":"https://github.com/sailor.png","language":"Ruby","readme":"# Quiq\n\nQuiq is a distributed task queue backed by Redis to process jobs in background.\n\nIt relies on asynchronous IOs to process multiple jobs simultaneously. The event loop is provided by the [Async](https://github.com/socketry/async) library and many other gems of the [Socketry](https://github.com/socketry) family.\n\nIt can be used without Rails, but will play nicely with [ActiveJob](https://guides.rubyonrails.org/active_job_basics.html) even though it's not supported officialy (more details [here](#activejob-support)).\n\nThe library is in a very early stage, it is **not suitable for production** yet.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'quiq'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install quiq\n\n## Usage\n\nTo launch the workers, you can use the `quiq` command.\n\n```\nUsage: quiq [options]\n    -p, --path PATH                  Location of the workers to load\n    -q, --queues NAMES               Comma-separated list of queues to poll\n    -l, --log-level LEVEL            The logging level\n    -v, --version                    Output version and exit\n    -h, --help                       Show this message\n```\n\nThis is how to use it with a Rails application using [ActiveJob](https://guides.rubyonrails.org/active_job_basics.html)\n\n    $ bundle exec quiq -p ./config/environment.rb -q critical,medium,low -l WARN\n\n## Configuration\n\nHere is an example of a configuration within a Rails application:\n\n```ruby\nQuiq.configure do |config|\n  config.redis = 'redis://localhost:6379'\n  config.logger = Rails.logger\nend\n```\n\n### ActiveJob support\n\nAs there is no official support for Quiq in ActiveJob, you must monkey patch it to use it as you would do with any other background jobs system. You can find a complete example here: [testapp/config/initializers/quiq.rb](https://github.com/sailor/quiq/blob/master/testapp/config/initializers/quiq.rb)\n\n```ruby\nmodule ActiveJob\n  module QueueAdapters\n    class QuiqAdapter\n      def enqueue(job)\n        Quiq::Client.push(job)\n      end\n\n      def enqueue_at(job, timestamp)\n        Quiq::Client.push(job, scheduled_at: timestamp)\n      end\n\n      class JobWrapper\n        class \u003c\u003c self\n          def perform(job_data)\n            Base.execute job_data\n          end\n        end\n      end\n    end\n  end\nend\n```\n\n## Jobs\n\nAs it is using the [Async](https://github.com/socketry/async) gem, we can use the many features provided by this library.\n\nYou can access the underlying `Async::Task` by using `Quiq.current_task`.\n\nA very dumb example:\n\n```ruby\nclass TestJob \u003c ApplicationJob\n  def perform(data, wait)\n    puts \"Receiving new job: #{data}\"\n    Quiq.current_task.sleep wait # Non blocking call\n    puts \"Time to wake up after #{wait} seconds\"\n  end\nend\n```\n\nMore interesting use case. If you combine `quiq` with the [async-http](https://github.com/socketry/async-http) gem, you'll be able to make asynchronous HTTP calls:\n\n```ruby\nrequire 'uri'\nrequire 'async/http/internet'\n\nclass HttpJob \u003c ApplicationJob\n  def perform(url)\n    uri = URI(url)\n\n    client = Async::HTTP::Internet.new\n    response = client.get(url)\n    Quiq.logger.info response.read\n  end\nend\n```\n\n### Scheduled jobs\n\nSince Quiq supports ActiveJob interface you can use the same approach to schedule jobs for the future.\n\n```ruby\nTestJob.set(wait: 5.seconds).perform_later(1, 2)\n```\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## Benchmarks\n\nTo benchmark the system you can use the `quiqload` binary. To launch it, execute:\n\n    $ time bin/quiqload -n 10_000 -w 1\n\n```\nUsage: quiqload [options]\n    -n, --number JOBS                Number of jobs to enqueue\n    -w, --wait DURATION              Idle time within each job (in seconds)\n    -h, --help                       Show this message\n```\n\n## Todo\n\n- [ ] Graceful shutdown\n- [x] Customizable logger\n- [x] Dead-letter queue\n- [x] Scheduler\n- [ ] Specs\n- [x] Retry system\n- [ ] Batches support\n- [x] Load testing script\n- [ ] Admin user interface\n- [ ] Rate limiting capabilities\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/sailor/quiq.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsailor%2Fquiq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsailor%2Fquiq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsailor%2Fquiq/lists"}