Skip to content

Instantly share code, notes, and snippets.

@jeremyf
Created October 29, 2014 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyf/1f4e82875d4918a5332b to your computer and use it in GitHub Desktop.
Save jeremyf/1f4e82875d4918a5332b to your computer and use it in GitHub Desktop.
# This is a theoretical means of writing a command line tool for pushing jobs
# into Resque. This is what we've explored. It allows us to keep our workers
# and other models in the same repository.
require 'resque'
# In the worker application, the SomeWorker class is defined and has methods for
# performing the work. This
class SomeWorker
def initialize(pid)
@pid = pid
end
end
# I think we need this.
class MarshaledJob
def self.perform(marshaled_job)
Marshal.load(Base64.decode64(marshaled_job)).run
end
end
job = SomeWorker.new(ARGV[0])
Resque.enqueue_to queue, MarshaledJob, Base64.encode64(Marshal.dump(job))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment