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

Version 4 Upgrade #133

Closed
kapso opened this issue Oct 17, 2015 · 12 comments
Closed

Version 4 Upgrade #133

kapso opened this issue Oct 17, 2015 · 12 comments

Comments

@kapso
Copy link

kapso commented Oct 17, 2015

Little confused about the upgrade -- difference between Easy path & Hard path? We have many future (unique) jobs scheduled, do both upgrade paths require us to delete jobs?

If we just upgrade the code and dont delete the jobs, would things just work?

@mhenrixon
Copy link
Owner

If you state your needs I might be able to help you. Can you post the workers and the job hash from sidekiq so that I can see if there is an easy upgrade path I could develop for you?

@kapso
Copy link
Author

kapso commented Oct 18, 2015

Here's one example worker.

ChargeWorker.perform_in(Settings.charge_retry_days.days, @object.id, retry_random: rand.to_s)
class ChargeWorker < BaseWorker
  sidekiq_options queue: :charge,
                  unique: :until_executed

  def perform(id, _options = {})
    ApplyCharge.call(id: id)
  end
end

We have other workers too, but this is one example. Thanks so much for your help.

@mhenrixon
Copy link
Owner

Ok so first things first! You job will always be unique because the arguments is using some type of random but maybe that is ok? I also don't see what your job configuration was previously which would be helpful to understand what is needed.

@kapso
Copy link
Author

kapso commented Oct 19, 2015

The only difference is unique: true old unique job syntax

@mhenrixon
Copy link
Owner

First of all the job will always be unique, not sure if you are aware of that?

@kapso
Copy link
Author

kapso commented Oct 19, 2015

Yea I understand that :) thats how it was intended due to retry_random: rand.to_s

@mhenrixon
Copy link
Owner

But you could as well not have it unique over that random thing. Every job with the id will be unique.

@kapso
Copy link
Author

kapso commented Oct 20, 2015

When the charge is processed for the first time i.e when job queued for the first time then we only use - ChargeWorker.perform_in(Settings.charge_retry_days.days, @object.id) its for this use case that we are using unique jobs.

@mhenrixon
Copy link
Owner

What did the worker look like before? I am trying to understand what the job hash looks like in redis.

@kapso
Copy link
Author

kapso commented Oct 21, 2015

This is what it looks like right now - gem 'sidekiq-unique-jobs', '3.0.15'

class ChargeWorker < BaseWorker
  sidekiq_options queue: :charge,
                  unique: true

  def perform(id, _options = {})
    ApplyCharge.call(id: id)
  end
end

@mhenrixon
Copy link
Owner

From what I can gather the example job should be upgraded automagically. Just make sure that the ApplyCharge class is protecting against actually applying charges by id more than once. I can only guarantee certain types of uniqueness most of them constrained to 1 hour maximum.

@kapso
Copy link
Author

kapso commented Oct 21, 2015

Got it. Thanks for your inputs and your work on this gem.

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

No branches or pull requests

2 participants