Skip to content

Add way to define Sidekiq sender class#57

Open
jylamont wants to merge 4 commits intomasterfrom
feature/define-sidekiq-worker
Open

Add way to define Sidekiq sender class#57
jylamont wants to merge 4 commits intomasterfrom
feature/define-sidekiq-worker

Conversation

@jylamont
Copy link
Contributor

@jylamont jylamont commented Nov 1, 2015

This is one possible solution to #51 and #54. Essentially you can define your own SidekiqWorker class to send API requests to Vero.

Something like this...

class MyVeroSidekiqWorker < Vero::SidekiqWorker
   sidekiq_options retry: 2, queue: 'another_queue'
   sidekiq_retry_in { |count| 60 }
end

and in vero.rb

Vero::App.init do |config|
   # ...
   config.sender_class = MyVeroSidekiqWorker
end

What do you think @damienbrz, @shaneog, @lemboy, @criticerz?

@lemboy
Copy link

lemboy commented Nov 2, 2015

Yes, we did something like this - added possible use custom sidekiq worker #56.

@shaneog
Copy link
Contributor

shaneog commented Nov 2, 2015

I like it. It's cleaner than the current monkey patching I'm doing.

Now, if we could remove the hard dependency on sucker_punch it would be great 👍 😄

Comment on lines +18 to 20
def api_klass(api_class)
eval(api_class.to_s)
end
Copy link

Choose a reason for hiding this comment

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

Using eval here introduces potential security risks since it executes arbitrary Ruby code. The safer approach is to use Rails' constantize method which is specifically designed for class name resolution: api_class.to_s.constantize

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

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.

3 participants