{"id":18728852,"url":"https://github.com/rubyonworld/havanna","last_synced_at":"2025-11-12T05:30:20.479Z","repository":{"id":174007937,"uuid":"540252481","full_name":"RubyOnWorld/havanna","owner":"RubyOnWorld","description":"Similar to Rack's config.ru, Havanna has an entry point file where you explicitly declare handlers for your queues.","archived":false,"fork":false,"pushed_at":"2022-09-23T02:41:57.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T14:27:20.808Z","etag":null,"topics":["config","havanna","rack","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/RubyOnWorld.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-09-23T02:41:43.000Z","updated_at":"2022-09-27T21:06:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f72094e-feb9-4f12-ad63-aeeda7b988c0","html_url":"https://github.com/RubyOnWorld/havanna","commit_stats":null,"previous_names":["rubyonworld/havanna"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhavanna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhavanna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhavanna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyOnWorld%2Fhavanna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyOnWorld","download_url":"https://codeload.github.com/RubyOnWorld/havanna/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239599040,"owners_count":19665911,"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":["config","havanna","rack","ruby"],"created_at":"2024-11-07T14:24:31.938Z","updated_at":"2025-11-12T05:30:20.445Z","avatar_url":"https://github.com/RubyOnWorld.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Havanna\n=======\n\nRuby workers with [Disque][disque].\n\n\nUsage\n-----\n\nSimilar to Rack's `config.ru`, Havanna has an entry point file where you\nexplicitly declare handlers for your queues.\nThe minimum you need to use Havanna is to create a `Havannafile`:\n\n```\nrequire \"app\"\n\nHavanna.run(Hello: -\u003e job {\n  puts(\"Hello, #{job}\")\n})\n```\n\nNow on the command line, start Havanna:\n\n```\n$ havanna start\n```\n\nIn a different window, try queuing a job using Disque's built-in client:\n\n```\n$ disque addjob Hello world 5000\n```\n\nAs expected, you should see the string \"Hello, world\" in the terminal where you\nstarted Havanna.\n\n\nWorkers\n-------\n\nIf you prefer to use classes to model your workers, there's `Havanna::Worker`.\nFor instance, this could be `workers/mailer.rb`:\n\n```ruby\nrequire \"havanna/worker\"\n\nclass Mailer \u003c Havanna::Worker\n  def call(item)\n    puts(\"Emailing #{item}...\")\n\n    # Actually do it.\n  end\nend\n```\n\nThen your `Havannafile` would look like this:\n\n```ruby\nrequire \"app\"\n\nHavanna.run(Mailer)\n```\n\n\nAdministration\n--------------\n\nOnce you're up and running, deploy your workers with `-d` for daemonization:\n\n```\n$ havanna start -d\n```\n\nStop the worker pool by issuing a `stop` command:\n\n```\n$ havanna stop\n```\n\nThis will wait for all workers to exit gracefully.\n\nFor more information, run:\n\n```\n$ havanna -h\n```\n\n\nDesign notes\n------------\n\nHavanna assumes that your workers perform a fair amount of I/O (probably one\nof the most common reasons to send jobs to the background). We will optimize\nHavanna for this use case.\n\nCurrently, Havanna runs multiple threads per worker. However, we may `fork(2)`\nif we find that's better for multiple-core utilization under MRI.\n\n\nAlternatives\n------------\n\nIt's very likely that Havanna is not for you. While I use it in production,\nit's small and doesn't do much.\n\nThese are the alternatives I know of in Rubyland:\n\n- [Disc][disc]: By my friend [pote][pote]. It supports more customization of\n  workers and queues, takes configuration from environment variables and can\n  take advantage of Celluloid if you're using it.\n\n- [DisqueJockey][disque_jockey]: I don't know much about this one, but\n  apparently it's even more configurable, has a DSL and (naturally) might be\n  a better fit if you use/like Rails.\n\n\nAbout the name\n--------------\n\nHavanna is inspired by [Ost][ost] and [ost(1)][ost-bin]. [soveran][soveran]\nnamed Ost after a café, and I happened to be sitting at another café when I\nstarted to work on this library. Its name: [Havanna][havanna].\n\nBy the way, before becoming a café, Havanna produced the best\n*[alfajores][alfajores]* in Argentina. They only had one store in Mar del\nPlata (~400km away from Buenos Aires), so it became a tradition to bring these\nexquisite *alfajores* when you returned from a trip to the beach.  Several\nyears later they opened stores in Buenos Aires and elsewhere and became a\ncoffee shop.\n\n\n[alfajores]:     https://www.google.com.ar/search?q=alfajor+argentino\u0026tbm=isch\n[disc]:          https://github.com/pote/disc\n[disque]:        https://github.com/antirez/disque\n[disque_jockey]: https://github.com/DevinRiley/disque_jockey\n[havanna]:       https://www.google.com.ar/search?q=havanna+cafe\u0026tbm=isch\n[ost-bin]:       https://github.com/djanowski/ost-bin\n[ost]:           https://github.com/soveran/ost\n[pote]:          https://twitter.com/poteland\n[soveran]:       https://twitter.com/soveran\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhavanna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyonworld%2Fhavanna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyonworld%2Fhavanna/lists"}