Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to customize sidekiq_options in listeners #13

Closed
wants to merge 6 commits into from

Conversation

k-rudy
Copy link

@k-rudy k-rudy commented Mar 24, 2017

Hey guys,

This PR adds support of custom sidekiq_options when registering a listener.
In order to work it requires few changes in Wisper krisleech/wisper#159.

It supports all existing configurations + adds ability to pass additional options via the following syntax:

cancel_order.subscribe(OrderNotifier.new, async: { queue: 'custom', retry: false })

Decreased coverage is expected as one of the specs is suspended until wisper PR is merged. After wisper part is merged we'll need to remove this line https://github.com/krisleech/wisper-sidekiq/pull/13/files#diff-078c1c61de993e867792139abaaba7d3R42 that will enable the spec for the new syntax.

JRuby build is failing for unknown reason. I wish I could ssh to container to debug it but have no access. Locally tests work fine on this JRuby version though. Appreciate any ideas. Also @krisleech if you could restart the master branch build (it was not run for 2 years) to make sure it's failing definitely because of the changes in this PR and not because of something else.

Thanks for consideration and appreciate your thoughts.

@coveralls
Copy link

Coverage Status

Coverage decreased (-10.3%) to 89.655% when pulling 26d588b on Profinda:master into fc5a529 on krisleech:master.

@rromanchuk
Copy link

@k-rudy thanks for doing this, deploying your fork now

Gemfile Outdated
@@ -8,6 +8,9 @@ gem 'rspec'
gem 'coveralls', require: false

gem 'psych', platforms: :rbx
gem 'rack', '~> 1.6.5'
gem 'tins', '~> 1.6.0'
gem 'term-ansicolor', '~> 1.3.2'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these dependencies used for?

Copy link
Author

@k-rudy k-rudy Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are already used by the gem. Nothing new was added. When not frozen - they are resolved to higher versions by bundler and as a result build failed for earlier ruby versions. See https://travis-ci.org/krisleech/wisper-sidekiq/builds/214653091 for details

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I guess they might not be needed since updated the Ruby versions on CI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, will remove those changes then

@krisleech
Copy link
Owner

I'm definitely open to these changes:

module Wisper
    class SidekiqBroadcaster
 +    attr_reader :options
 +
 +    def initialize(options = {})
 +      @options = options
 +    end
 +
      def broadcast(subscriber, publisher, event, args)
 -      subscriber.delay.public_send(event, *args)
 +      subscriber.delay(options).public_send(event, *args)
      end

But I'm not convinced that we need to change Wisper, as per the discussion here: krisleech/wisper#159

@krisleech
Copy link
Owner

If you merge master (which I just updated) CI should pass :)

@coveralls
Copy link

coveralls commented Apr 20, 2017

Coverage Status

Coverage decreased (-9.6%) to 88.136% when pulling 23a4b9c on Profinda:master into 712d5a1 on krisleech:master.

@krisleech
Copy link
Owner

Any progress on this? Thanks.

@k-rudy
Copy link
Author

k-rudy commented Feb 15, 2018

@krisleech it still waits for krisleech/wisper#159 to be merged.

@rwojsznis rwojsznis mentioned this pull request Jul 14, 2018
@krisleech
Copy link
Owner

Closing in favor of #17

@krisleech krisleech closed this Jul 31, 2018
@k-rudy
Copy link
Author

k-rudy commented Jul 31, 2018

@krisleech what's the example of defining options. From the README it's not straightforward:

In order to define custom sidekiq_options 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.

It it like this:

WisperSubscriber.subscribe(UserListener, async: true, sidekiq_options: { queue: 'custom' })

?

@rwojsznis
Copy link
Contributor

@k-rudy please take a look at - https://github.com/krisleech/wisper-sidekiq/pull/17/files#diff-2d6df3b20624fe23ec544f0a2cdecd1bR21 - you basically define class method on your listener class; feel free to improve readme via PR! (it was my doing - the change, but right now I'm pretty occupied) cheers! 🍻

@k-rudy
Copy link
Author

k-rudy commented Aug 9, 2018

@emq got it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants