{"id":15605965,"url":"https://github.com/kares/delayed-threaded","last_synced_at":"2026-03-08T13:30:16.520Z","repository":{"id":62556993,"uuid":"131625231","full_name":"kares/delayed-threaded","owner":"kares","description":null,"archived":false,"fork":false,"pushed_at":"2018-05-07T13:01:11.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T13:11:08.826Z","etag":null,"topics":["activerecord","delayed-job","jruby","jruby-rack","threaded"],"latest_commit_sha":null,"homepage":null,"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/kares.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-30T17:24:04.000Z","updated_at":"2021-03-23T21:23:46.000Z","dependencies_parsed_at":"2022-11-03T06:15:30.657Z","dependency_job_id":null,"html_url":"https://github.com/kares/delayed-threaded","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kares%2Fdelayed-threaded","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kares%2Fdelayed-threaded/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kares%2Fdelayed-threaded/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kares%2Fdelayed-threaded/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kares","download_url":"https://codeload.github.com/kares/delayed-threaded/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239904300,"owners_count":19716251,"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":["activerecord","delayed-job","jruby","jruby-rack","threaded"],"created_at":"2024-10-03T04:20:27.814Z","updated_at":"2026-03-08T13:30:16.460Z","avatar_url":"https://github.com/kares.png","language":"Ruby","readme":"# Delayed::Threaded\n\nAllows to start [DJ][0] in the same process using `Thread.new { ... }`\n\nExtracted from [JRuby-Rack-Worker][1]: an effort to run Ruby workers in threads\nwith Java (JRuby-Rack) deployments (previously known as `Delayed::JRubyWorker`).\n\n**NOTE: JRuby only, for now (PRs welcome)!**\n\n## Installation\n\n```ruby\ngem 'delayed-threaded'\n```\n\nand `bundle` or install it yourself as `gem install delayed-threaded`.\n\n## Usage\n\n```ruby\ndef start_worker\n  options = { :quiet =\u003e true }\n  if read_ahead = ENV['READ_AHEAD'] # DEFAULT_READ_AHEAD = 5\n    options[:read_ahead] = read_ahead.to_i\n  end\n  if sleep_delay = ENV['SLEEP_DELAY'] # DEFAULT_SLEEP_DELAY = 5\n    options[:sleep_delay] = sleep_delay.to_f\n  end\n\n  # some options are set to work per-thread (as a thread-local).\n  worker = Delayed::Threaded::Worker.new(options)\n  worker.start\nrescue Exception =\u003e e\n  msg = \"FATAL #{e.inspect}\"\n  if backtrace = e.backtrace\n    msg \u003c\u003c \":\\n  #{backtrace.join(\"\\n  \")}\"\n  end\n  STDERR.puts(msg)\nend\n\n# while other options are global and do not make sense to be set per-thread\nDelayed::Worker.queues = (ENV['QUEUES'] || ENV['QUEUE'] || '').split(',')\nDelayed::Worker.min_priority = ENV['MIN_PRIORITY'] if ENV['MIN_PRIORITY']\nDelayed::Worker.max_priority = ENV['MAX_PRIORITY'] if ENV['MAX_PRIORITY']\n\nThread.new { start_worker }\n```\n\n### ActiveRecord\n\nThere's an optional integration with the [ActiveRecord][2] backend, to clear\nthe connections after work (as the worker sleeps), setup as a plugin using :\n\n```ruby\nrequire 'delayed/active_record/release_connection_plugin.rb'\n````\n\nand a somehow fail-\"safer\" lock clearing mechanism in case of backend errors\n\n```ruby\n# Replace DJ's default ClearLocks plugin with a fail-safe version \n# e.g. when a connection goes down in the middle of job processing, \n# `Delayed::Job.clear_locks!` causes a double fault to propagate.\nrequire 'delayed/fail_safe/clear_locks_plugin.rb'\n```\n\nNOTE: **delayed_job** might not be the right tool for a fail-safe worker job.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\nThen, run `rake test` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\n## Copyright\n\nCopyright (c) 2018 [Karol Bucek](http://kares.org).\nSee LICENSE (http://en.wikipedia.org/wiki/MIT_License) for details.\n\n[0]: https://github.com/collectiveidea/delayed_job\n[1]: https://github.com/kares/jruby-rack-worker\n[2]: https://github.com/collectiveidea/delayed_job_active_record\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkares%2Fdelayed-threaded","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkares%2Fdelayed-threaded","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkares%2Fdelayed-threaded/lists"}