Class: Adaptor::ResqueAdaptor
- Inherits:
-
LanGrove::Adaptor::Base
- Object
- LanGrove::Adaptor::Base
- Adaptor::ResqueAdaptor
- Defined in:
- lib/adaptor/resque_adaptor.rb
Instance Method Summary collapse
- #connector(params, &block) ⇒ Object
-
#initialize(root, config, deamon_name) ⇒ ResqueAdaptor
constructor
A new instance of ResqueAdaptor.
Constructor Details
#initialize(root, config, deamon_name) ⇒ ResqueAdaptor
Returns a new instance of ResqueAdaptor.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/adaptor/resque_adaptor.rb', line 36 def initialize( root, config, deamon_name ) raise config_exception( "#{self.class} requires :plugin:" ) if ( config.nil? or config[:plugin].nil? ) super raise config_exception( "#{self.class} requires :plugin: to define :queue:" ) if ( config[:plugin][:queue].nil? ) @queue = config[:plugin][:queue] # # Departure from traditional use of resque... # - Each job has its own failed queue # - Failed jobs are not resubmittable # - The failure queue contains the exception # failed_queue = "#{@queue}_failed" @failed_job_class = Object.const_set( failed_queue.camelize, Class.new do self.instance_variable_set( :@queue, failed_queue ) end ) @hostname = config[:plugin][:hostname].nil? ? 'localhost' : config[:plugin][:hostname] @port = config[:plugin][:port].nil? ? 6379 : config[:plugin][:port] Resque.redis = Redis.new( :host => @hostname, :port => @port ) @type = :not_eventmachine end |
Instance Method Details
#connector(params, &block) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/adaptor/resque_adaptor.rb', line 107 def connector( params, &block ) # # This yields Resque::Job(s), # one at a time, # into the caller. # wait_for_job( @queue, &block ) end |