Class: QueueingProxy::DSL::Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/queueing_proxy/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host = 'localhost', port = 80, workers = 4, &block) ⇒ Backend

Returns a new instance of Backend.



8
9
10
11
12
# File 'lib/queueing_proxy/dsl.rb', line 8

def initialize(host='localhost', port=80, workers=4, &block)
  @host, @port, @workers, @beanstalk_host, @tube = host, port, workers, 'localhost', 'default'
  instance_exec(&block) if block_given?
  self
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/queueing_proxy/dsl.rb', line 6

def host
  @host
end

#tubeObject (readonly)

Returns the value of attribute tube.



6
7
8
# File 'lib/queueing_proxy/dsl.rb', line 6

def tube
  @tube
end

Instance Method Details

#logger(logger) ⇒ Object



28
29
30
31
# File 'lib/queueing_proxy/dsl.rb', line 28

def logger(logger)
  @logger = logger
  self
end

#queue_with(beanstalk, tube) ⇒ Object



14
15
16
17
# File 'lib/queueing_proxy/dsl.rb', line 14

def queue_with(beanstalk, tube)
  @beanstalk, @tube = beanstalk, tube
  self
end

#workers(workers = nil) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/queueing_proxy/dsl.rb', line 19

def workers(workers=nil)
  if workers
    @workers = workers
    self
  else
    (1..@workers).map { Worker.new(@logger, @host, @port, @beanstalk_host, @tube) }
  end
end