{"id":13484458,"url":"https://github.com/jondot/sneakers","last_synced_at":"2025-05-13T19:13:40.471Z","repository":{"id":1016555,"uuid":"13441956","full_name":"jondot/sneakers","owner":"jondot","description":"A fast background processing framework for Ruby and RabbitMQ","archived":false,"fork":false,"pushed_at":"2024-06-26T20:05:06.000Z","size":1536,"stargazers_count":2249,"open_issues_count":61,"forks_count":330,"subscribers_count":40,"default_branch":"master","last_synced_at":"2025-05-13T17:14:38.576Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/jondot/sneakers","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/jondot.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2013-10-09T12:41:36.000Z","updated_at":"2025-05-10T21:59:20.000Z","dependencies_parsed_at":"2024-05-01T13:19:49.391Z","dependency_job_id":"e790a61b-7e2c-4ed6-8e9f-4b63efed0913","html_url":"https://github.com/jondot/sneakers","commit_stats":{"total_commits":462,"total_committers":114,"mean_commits":4.052631578947368,"dds":0.8614718614718615,"last_synced_commit":"21822705d98c4666ef6273fa44c6e4ddfc44b394"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jondot%2Fsneakers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jondot%2Fsneakers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jondot%2Fsneakers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jondot%2Fsneakers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jondot","download_url":"https://codeload.github.com/jondot/sneakers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254010813,"owners_count":21998995,"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-07-31T17:01:24.724Z","updated_at":"2025-05-13T19:13:40.425Z","avatar_url":"https://github.com/jondot.png","language":"Ruby","funding_links":[],"categories":["Ruby","Queues and Messaging","WebSocket"],"sub_categories":[],"readme":"# Sneakers has a New Home and a New Name\n\n⚠️⚠️⚠️ Sneakers users have decided to continue with a new repo\nand a new name: meet [ruby-amqp/kicks](https://github.com/ruby-amqp/kicks).\n\nUnfortunately, this repo was abandoned by its original author who has exclusive control\nover the RubyGems project. So the community of users has [decided to move it](https://github.com/jondot/sneakers/issues/452)\nto a different \"fork\" (continuation) under a new name.\n\n## What is Sneakers\n\n```\n      __\n  ,--'  \u003e\n  `=====\n\n```\n\nA high-performance RabbitMQ background processing framework for\nRuby.\n\nSneakers is being used in production for both I/O and CPU intensive workloads, and have achieved the goals of high-performance and 0-maintenance, as designed.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sneakers'\n```\n\nAnd then execute:\n\n```shell-session\n$ bundle\n```\n\nOr install it yourself as:\n\n```shell-session\n$ gem install sneakers\n```\n\n## Documentation\n\nA quick start guide is available in the section below.\n\nVisit the [wiki](https://github.com/jondot/sneakers/wiki) for more detailed\ndocumentation and [GitHub releases](https://github.com/jondot/sneakers/releases) for release\nnotes.\n\nA [change log](./ChangeLog.md) is also available.\n\n## Quick start\n\nSet up a Gemfile\n\n```ruby\nsource 'https://rubygems.org'\ngem 'sneakers'\ngem 'json'\ngem 'redis'\n```\n\nHow do we add a worker? Firstly create a file and name it as `boot.rb`\nthen create a worker named as `Processor`.\n\n\u003e touch boot.rb\n\n```ruby\nrequire 'sneakers'\nrequire 'redis'\nrequire 'json'\n\n$redis = Redis.new\n\nclass Processor\n  include Sneakers::Worker\n  from_queue :logs\n\n  def work(msg)\n    err = JSON.parse(msg)\n    if err[\"type\"] == \"error\"\n      $redis.incr \"processor:#{err[\"error\"]}\"\n    end\n\n    ack!\n  end\nend\n```\n\nLet's test it out quickly from the command line:\n\n```shell-session\n$ sneakers work Processor --require boot.rb\n```\n\nWe just told Sneakers to spawn a worker named `Processor`, but first `--require` a file that we dedicate to setting up environment, including workers and what-not.\n\nIf you go to your RabbitMQ admin now, you'll see a new queue named `logs` was created. Push a couple messages like below:\n\n```javascript\n{\n   \"type\": \"error\",\n   \"message\": \"HALP!\",\n   \"error\": \"CODE001\"\n}\n```\n\nPublish a message with the [bunny](https://github.com/ruby-amqp/bunny) gem RabbitMQ client:\n\n```ruby\nrequire 'bunny'\n\nconn = Bunny.new\nconn.start\n\nch = conn.create_channel\nch.default_exchange.publish({ type: 'error', message: 'HALP!', error: 'CODE001' }.to_json, routing_key: 'logs')\n\nconn.close\n```\n\nAnd this is the output you should see at your terminal.\n\n```\n2013-10-11T19:26:36Z p-4718 t-ovqgyb31o DEBUG: [worker-logs:1:213mmy][#\u003cThread:0x007fae6b05cc58\u003e][logs][{:prefetch=\u003e10, :durable=\u003etrue, :ack=\u003etrue, :heartbeat_interval=\u003e2, :exchange=\u003e\"sneakers\"}] Working off: log log\n2013-10-11T19:26:36Z p-4718 t-ovqgyrxu4 INFO: log log\n2013-10-11T19:26:40Z p-4719 t-ovqgyb364 DEBUG: [worker-logs:1:h23iit][#\u003cThread:0x007fae6b05cd98\u003e][logs][{:prefetch=\u003e10, :durable=\u003etrue, :ack=\u003etrue, :heartbeat_interval=\u003e2, :exchange=\u003e\"sneakers\"}] Working off: log log\n2013-10-11T19:26:40Z p-4719 t-ovqgyrx8g INFO: log log\n```\n\nWe'll count errors and error types with Redis.\n\n``` shell-session\n$ redis-cli monitor\n1381520329.888581 [0 127.0.0.1:49182] \"incr\" \"processor:CODE001\"\n```\n\nWe're basically done with the ceremonies and all is left is to do some real work.\n\n### Looking at metrics\n\nLet's use the `logging_metrics` provider just for the sake of fun of seeing the metrics as they happen.\n\n```ruby\n# boot.rb\nrequire 'sneakers'\nrequire 'redis'\nrequire 'json'\nrequire 'sneakers/metrics/logging_metrics'\nSneakers.configure(metrics: Sneakers::Metrics::LoggingMetrics.new)\n\n# ... rest of code\n```\n\nNow push a message again and you'll see:\n\n```\n2013-10-11T19:44:37Z p-9219 t-oxh8owywg INFO: INC: work.Processor.started\n2013-10-11T19:44:37Z p-9219 t-oxh8owywg INFO: TIME: work.Processor.time 0.00242\n2013-10-11T19:44:37Z p-9219 t-oxh8owywg INFO: INC: work.Processor.handled.ack\n```\n\nWhich increments `started` and `handled.ack`, and times the work unit.\n\nFrom here, you can continue over to the\n[Wiki](https://github.com/jondot/sneakers/wiki)\n\n# Docker\n\nIf you use Docker, there's some benefits to be had and you can use both\n`docker` and `docker-compose` with this project, in order to run tests,\nintegration tests or a sample worker without setting up RabbitMQ or the\nenvironment needed locally on your development box.\n\n* To build a container run `docker build . -t sneakers_sneakers`\n* To run non-integration tests within a docker container, run `docker run --rm\n  sneakers_sneakers:latest`\n* To run full integration tests within a docker topology including RabbitMQ,\n  Redis (for integration worker) run `scripts/local_integration`, which will\n  use docker-compose to orchestrate the topology and the sneakers Docker image\n  to run the tests\n* To run a sample worker within Docker, try the `TitleScraper` example by\n  running `script/local_worker`. This will use docker-compose as well. It will\n  also help you get a feeling for how to run Sneakers in a Docker based\n  production environment\n* Use `Dockerfile.slim` instead of `Dockerfile` for production docker builds.\n  It generates a more compact image, while the \"regular\" `Dockerfile` generates\n  a fatter image - yet faster to iterate when developing\n\n# Compatibility\n\n* Sneakers main branch: Ruby 3.0+\n* Sneakers 2.7.x and later (using Bunny 2.9): Ruby 2.2.x\n* Sneakers 1.1.x and later (using Bunny 2.x): Ruby 2.x\n* Sneakers 1.x.x and earlier: Ruby 1.9.x, 2.x\n\n# Contributing\n\nFork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).\n\n### Thanks:\n\nTo all Sneakers [Contributors](https://github.com/jondot/sneakers/graphs/contributors) - you make this happen, thanks!\n\n# Copyright\n\nCopyright (c) 2015-2018 [Dotan Nahum](http://gplus.to/dotan) [@jondot](http://twitter.com/jondot). See [LICENSE](LICENSE.txt) for further details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjondot%2Fsneakers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjondot%2Fsneakers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjondot%2Fsneakers/lists"}