{"id":20836308,"url":"https://github.com/igrigorik/em-jack","last_synced_at":"2025-10-13T09:02:14.830Z","repository":{"id":517569,"uuid":"145652","full_name":"igrigorik/em-jack","owner":"igrigorik","description":"An Evented Beanstalk Client","archived":false,"fork":false,"pushed_at":"2012-07-27T23:58:55.000Z","size":215,"stargazers_count":64,"open_issues_count":5,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T16:34:42.609Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://dj2.github.com/jack","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igrigorik.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-03-08T05:57:09.000Z","updated_at":"2024-02-21T09:47:07.000Z","dependencies_parsed_at":"2022-07-14T18:30:42.962Z","dependency_job_id":null,"html_url":"https://github.com/igrigorik/em-jack","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/igrigorik%2Fem-jack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fem-jack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fem-jack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igrigorik%2Fem-jack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igrigorik","download_url":"https://codeload.github.com/igrigorik/em-jack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252988548,"owners_count":21836557,"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":[],"created_at":"2024-11-18T00:29:29.037Z","updated_at":"2025-10-13T09:02:14.711Z","avatar_url":"https://github.com/igrigorik.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= EMJack\n\nAn attempt to wrap portions of the Beanstalk protocol with EventMachine. Every command\nwill return a deferrable object. That object will succeed or fail depending on the\nreply returned from Beanstalk.\n\nOne thing to keep in mind. The Beanstalk protocol executes all commands serially.\nSo, if you send a reserve command and there are no jobs Beanstalk _won't_ process\nany of the commands that come after the reserve until the reserve completes.\n\nThis is a bit of a gotcha when sending a series of reserve, delete, etc and there\nare no available jobs.\n\n= Dependencies\n - EventMachine\n - RSpec  (to run the tests)\n\n= Examples\n  EM.run {\n    jack = EMJack::Connection.new\n\n    r = jack.use('mytube')\n    r.callback { |tube| puts \"Using #{tube}\" }\n\n    r = jack.reserve\n    r.callback do |job|\n      puts job.jobid\n\n      r2 = jack.delete(job) { puts \"Successfully deleted\" }\n    end\n\n    r = jack.put(\"my message\", :ttr =\u003e 300) { |jobid| puts \"put successful #{jobid}\" }\n\n    r = jack.stats\n    r.callback { |stats| puts \"Server up for #{stats['uptime']} seconds\" }\n\n    r = jack.stats(:tube, \"mytube\")\n    r.callback { |stats| puts \"Total jobs #{stats['total-jobs']}\" }\n\n    r = jack.list(:used)\n    r.callback { |tubes| puts \"There are #{tubes.length} tubes defined\" }\n  }\n\n  Each of the Jack commands allows an optional block to be provided. If the block is given\n  it will be setup as the callback on the deferrable.\n\n  EMJack#each_job is useful for scenarios where the client is a job worker\n  and intended to process jobs continuously as they become available. Once\n  the queue is empty, the client will block and wait for a new job.\n\n  If multiple workers connect to the queue Beanstalkd will round-robin between\n  the workers.\n\n    EM.run {\n      jack = EMJack::Connection.new\n\n      jack.each_job do |job|\n        puts \"Got job ##{job.jobid}: #{job}\"\n\n        if process(job)\n          r = jack.delete(job)\n          r.callback { puts \"*Deleted #{job}*\" }\n        else\n        end\n      end\n\n      def process(job)\n        # Some kind of job processing\n      end\n    }\n\n\n= Contact\nIf you've got any questions, comments or bugs, please let me know. You can\ncontact me by email at dj2 at everburning dot com.\n\n\n= Contributors\nCharles Melbye (cmelbye)\nPeter Kieltyka (pkieltyka)\nMartyn Loughran (mloughran)\nMike Perham (mperham)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrigorik%2Fem-jack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figrigorik%2Fem-jack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figrigorik%2Fem-jack/lists"}