lib/stalker.rb in stalker-0.5.1 vs lib/stalker.rb in stalker-0.6.0
- old
+ new
@@ -4,10 +4,15 @@
require 'timeout'
module Stalker
extend self
+ def connect(url)
+ @@url = url
+ beanstalk
+ end
+
def enqueue(job, args={}, opts={})
pri = opts[:pri] || 65536
delay = opts[:delay] || 0
ttr = opts[:ttr] || 120
beanstalk.use job
@@ -121,9 +126,10 @@
def beanstalk
@@beanstalk ||= Beanstalk::Pool.new([ beanstalk_host_and_port ])
end
def beanstalk_url
+ return @@url if defined?(@@url) and @@url
ENV['BEANSTALK_URL'] || 'beanstalk://localhost/'
end
class BadURL < RuntimeError; end