{"id":13747405,"url":"https://github.com/krisleech/wisper-sidekiq","last_synced_at":"2025-04-04T10:09:57.146Z","repository":{"id":20828323,"uuid":"24114257","full_name":"krisleech/wisper-sidekiq","owner":"krisleech","description":"Asynchronous event publishing for Wisper using Sidekiq","archived":false,"fork":false,"pushed_at":"2024-07-13T06:30:54.000Z","size":45,"stargazers_count":86,"open_issues_count":4,"forks_count":50,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T00:11:15.680Z","etag":null,"topics":[],"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/krisleech.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":"2014-09-16T19:21:43.000Z","updated_at":"2025-02-14T15:52:01.000Z","dependencies_parsed_at":"2024-02-11T15:54:34.009Z","dependency_job_id":"002430cd-fe30-4276-adc6-59d0236f0c76","html_url":"https://github.com/krisleech/wisper-sidekiq","commit_stats":{"total_commits":50,"total_committers":11,"mean_commits":4.545454545454546,"dds":0.64,"last_synced_commit":"234731e4a32de2d515b04d718efe678aa1002338"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper-sidekiq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper-sidekiq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper-sidekiq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fwisper-sidekiq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/wisper-sidekiq/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157283,"owners_count":20893220,"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-08-03T06:01:27.788Z","updated_at":"2025-04-04T10:09:57.126Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Wisper::Sidekiq\n\nProvides [Wisper](https://github.com/krisleech/wisper) with asynchronous event\npublishing using [Sidekiq](https://github.com/mperham/sidekiq).\n\n[![Gem Version](https://badge.fury.io/rb/wisper-sidekiq.png)](http://badge.fury.io/rb/wisper-sidekiq)\n[![Code Climate](https://codeclimate.com/github/krisleech/wisper-sidekiq.png)](https://codeclimate.com/github/krisleech/wisper-sidekiq)\n[![Build Status](https://travis-ci.org/krisleech/wisper-sidekiq.png?branch=master)](https://travis-ci.org/krisleech/wisper-sidekiq)\n[![Coverage Status](https://coveralls.io/repos/krisleech/wisper-sidekiq/badge.png?branch=master)](https://coveralls.io/r/krisleech/wisper-sidekiq?branch=master)\n\n## Installation\n\n### Sidekiq 5+\n\n```ruby\ngem 'wisper-sidekiq', '~\u003e 1.0'\n```\n\n### Sidekiq 4-\n\n```ruby\ngem 'wisper-sidekiq', '~\u003e 0.0'\n```\n\n## Usage\n\n```ruby\npublisher.subscribe(MyListener, async: true)\n```\n\nThe listener must be a class (or module), not an object. This is because Sidekiq\ncan not reconstruct the state of an object. However a class is easily reconstructed.\n\nAdditionally, you should also ensure that your methods used to handle events under `MyListener` are all declared as class methods:\n\n```ruby\nclass MyListener\n  def self.event_name\n  end\nend\n```\n\nWhen publishing events the arguments must be simple as they need to be\nserialized. For example instead of sending an `ActiveRecord` model as an argument\nuse its id instead.\n\nSee the [Sidekiq best practices](https://github.com/mperham/sidekiq/wiki/Best-Practices)\nfor more information.\n\n### YAML permitted classes\n\nThe gem internally uses YAML serialization/deserialization to pass your event data and subscribers to a sidekiq worker through redis.\n\nBy default, for security reasons, only a few basic classes like `String` or `Array` are permitted for deserialization.\n\nIf you are using custom types as your event data, you might run into\n```\nPsych::DisallowedClass:\n   Tried to load unspecified class: MyEventData1\n```\n\nIn that case, you can explicitly allow custom types using\n\n```ruby\nWisper::Sidekiq.configure do |config|\n  config.register_safe_types(MyEventData1, MyEventData2)\nend\n```\n\nAlternatively, you can opt-in for unsafe YAML loading that allows the deserialization of all classes using\n\n```ruby\nWisper::Sidekiq.configure do |config|\n  config.use_unsafe_yaml!\nend\n```\n\nKeep in mind that doing this can lead to [RCE vulneraibility](https://staaldraad.github.io/post/2019-03-02-universal-rce-ruby-yaml-load/) if an unauthorised actor gets the write access to your redis server.\n\n### Passing down sidekiq options\n\nIn order to define custom [sidekiq_options](https://github.com/mperham/sidekiq/wiki/Advanced-Options#workers) you can add `sidekiq_options` class method in your subscriber definition - those options will be passed to Sidekiq's `set` method just before scheduling the asynchronous worker.\n\n### Passing down schedule options\n\nIn order be able to schedule jobs to be run in the future following [Scheduled Jobs](https://github.com/mperham/sidekiq/wiki/Scheduled-Jobs) you can add `sidekiq_schedule_options` class method in your subscriber definition - those options will be passed to Sidekiq's `perform_in` method when the worker is called.\n\nThis feature is not as powerful as Sidekiq's API that allows you to set this on every job enqueue, in this case you're able to set this for the whole listener class like:\n```ruby\nclass MyListener\n  #...\n\n  def self.sidekiq_schedule_options\n    { perform_in: 5 }\n  end\n\n  #...\nend\n```\nOr you can set this per event (method called on the listener), like so:\n```ruby\nclass MyListener\n  #...\n\n  def self.sidekiq_schedule_options\n    { event_name: { perform_in: 5 } }\n  end\n\n  def self.event_name\n    #...\n  end\n\n  #...\nend\n```\nIn both cases the `perform_at` option is also available.\n\n## Compatibility\n\nThe same Ruby versions as Sidekiq are officially supported, but it should work\nwith any 2.x syntax Ruby including JRuby and Rubinius.\n\nSee the [build status](https://travis-ci.org/krisleech/wisper-sidekiq) for details.\n\n## Running Specs\n\n```\nscripts/sidekiq\nbundle exec rspec\n```\n\n## Contributing\n\nTo run sidekiq use `scripts/sidekiq`. This wraps sidekiq in [rerun](https://github.com/alexch/rerun)\nwhich will restart sidekiq when `specs/dummy_app` changes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fwisper-sidekiq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fwisper-sidekiq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fwisper-sidekiq/lists"}