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

Already on GitHub? Sign in to your account

Migration Guide From iron_worker to NG #122

Closed
paddycarver opened this Issue Jul 3, 2012 · 8 comments

Comments

Projects
None yet
3 participants
Contributor

paddycarver commented Jul 3, 2012

Need to write a guide for migrating your code and your way of thinking from the legacy iron_worker gem to the new iron_worker_ng gem.

@ghost ghost assigned paddycarver and carimura Jul 3, 2012

Contributor

frommww commented Jul 8, 2012

upload and queue/schedule are separate steps

upload is no longer automatic. needs to be done each time worker changes

.worker file

class no longer needed

merge goes away, replaced by require?

log goes away, replaced by puts

client.tasks.create

Contributor

paddycarver commented Jul 8, 2012

Awesome, thanks. I'll write this.

Contributor

carimura commented Jul 8, 2012

i'm working on this

Contributor

carimura commented Jul 8, 2012

@frommww thanks for the input but it's wasted effort when not assigned to you... just fyi for the future.

Contributor

frommww commented Jul 8, 2012

I just went through it in converting a system environment worker (that checks uname, release, memory, and gems on iw servers) and so it was fresh in my head. Was really just a for what it's worth.

Contributor

carimura commented Jul 8, 2012

(boom)

Contributor

carimura commented Jul 8, 2012

Ken Fromm, Systems Engineer

Contributor

carimura commented Jul 9, 2012

** If Rails, move out of the [rails_root]/app/workers directory into [rails_root]/workers

  1. Create empty .worker file
  2. no longer need require 'iron_worker'
  3. Pull all code out of class IronWroker::Base block
  4. Any files merged into the worker using merge() or merge_gem() or merge_dir() need to be included in the .worker file using file(), dir(), and gem() and also required in the new worker file
in old worker: merge File.join(File.dirname(__FILE__), '../models/usage.rb')
in new worker file: require 'models/usage.rb'
and in .worker file: file "../models/usage.rb"

in old worker: merge_gem "mongoid"
becomes: require "mongoid"
and in .worker file: gem "mongoid"
  1. attr_accessor's need to be either removed or turned into a payload
payload '{"some key":"some_value"}'
  1. Now, move all code out of run() method. If there are any methods outside of run() that are used inside of run(), make sure these are included ABOVE your code that's now outside of the run() method.
def run
  some code
  some_method()
end

def some_method
  some other code
end

becomes

def some_method
  some other code
end

some code
some_method()
  1. Now it's time to finish our .worker file
runtime
name
exec
dir, file, gem
  1. Let's configure our worker with the .iron.json file (or iron.json)
  2. Now let's test things out.

@ghost ghost assigned paddycarver Jul 17, 2012

@paddycarver paddycarver removed their assignment Apr 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment