lib/async_observer/queue.rb in beanstalker-0.1.1 vs lib/async_observer/queue.rb in beanstalker-0.1.2
- old
+ new
@@ -16,33 +16,33 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
require 'beanstalk-client'
-module AsyncObserver; end
+module Beanstalker; end
-class AsyncObserver::Queue; end
+class Beanstalker::Queue; end
-class << AsyncObserver::Queue
+class << Beanstalker::Queue
DEFAULT_PRI = 512
DEFAULT_FUZZ = 0
DEFAULT_DELAY = 0
DEFAULT_TTR = 120
DEFAULT_TUBE = 'default'
attr_accessor :queue, :after_put
# This is a fake worker instance for running jobs synchronously.
def sync_worker()
- require 'async_observer/worker'
- @sync_worker ||= AsyncObserver::Worker.new(binding)
+ require 'beanstalker/worker'
+ @sync_worker ||= Beanstalker::Worker.new(binding)
end
# This runs jobs synchronously; it's used when no queue is configured.
def sync_run(obj)
body = YAML.dump(obj)
- job = Beanstalk::Job.new(AsyncObserver::FakeConn.new(), 0, body)
+ job = Beanstalk::Job.new(Beanstalker::FakeConn.new(), 0, body)
sync_worker.dispatch(job)
sync_worker.do_all_work()
return 0, '0.0.0.0'
end
@@ -50,11 +50,11 @@
tube=DEFAULT_TUBE)
return sync_run(obj) if pri == :direct || !queue
queue.connect()
queue.use(tube)
info = [queue.yput(obj, pri, delay, ttr), queue.last_server]
- f = AsyncObserver::Queue.after_put
+ f = Beanstalker::Queue.after_put
f.call(*info) if f
return info
end
SUBMIT_OPTS = [:pri, :fuzz, :delay, :ttr, :tube]
@@ -93,11 +93,11 @@
def gen_args(args)
args.rrepr[1...-1]
end
end
-class AsyncObserver::FakeConn
+class Beanstalker::FakeConn
def delete(x)
end
def release(x, y, z)
end
@@ -179,10 +179,10 @@
class Date
def rrepr() "Date.parse('#{self.inspect}')" end
end
-module AsyncObserver::Extensions
+module Beanstalker::Extensions
def rrepr()
method = (respond_to? :get_cache) ? 'get_cache' : 'find'
"#{self.class.rrepr}.#{method}(#{id.rrepr})"
end
end