Class: DRbQueue::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/drb_queue/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
8
9
10
# File 'lib/drb_queue/configuration.rb', line 5

def initialize
  self.socket_location = '/tmp/drb_queue'
  self.num_workers = 1
  self.logger = Logger.new(STDOUT)
  self.error_handler = lambda { |e| logger.error(([e.message] + e.backtrace).join("\n")) }
end

Instance Attribute Details

#error_handlerObject

Returns the value of attribute error_handler.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def error_handler
  @error_handler
end

#immediateObject

Returns the value of attribute immediate.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def immediate
  @immediate
end

#loggerObject

Returns the value of attribute logger.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def logger
  @logger
end

#num_workersObject

Returns the value of attribute num_workers.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def num_workers
  @num_workers
end

#persistence_storeObject

Returns the value of attribute persistence_store.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def persistence_store
  @persistence_store
end

#socket_locationObject

Returns the value of attribute socket_location.



3
4
5
# File 'lib/drb_queue/configuration.rb', line 3

def socket_location
  @socket_location
end

Instance Method Details

#after_fork(&block) ⇒ Object



32
33
34
# File 'lib/drb_queue/configuration.rb', line 32

def after_fork(&block)
  after_fork_callbacks << block
end

#after_fork_callbacksObject



40
41
42
# File 'lib/drb_queue/configuration.rb', line 40

def after_fork_callbacks
  @after_fork_callbacks ||= []
end

#before_fork(&block) ⇒ Object



36
37
38
# File 'lib/drb_queue/configuration.rb', line 36

def before_fork(&block)
  before_fork_callbacks << block
end

#before_fork_callbacksObject



44
45
46
# File 'lib/drb_queue/configuration.rb', line 44

def before_fork_callbacks
  @before_fork_callbacks ||= []
end

#construct_persistence_storeObject



18
19
20
21
22
# File 'lib/drb_queue/configuration.rb', line 18

def construct_persistence_store
  return unless persistence_store

  persistence_store[0].new(persistence_store[1])
end

#immediate!Object



24
25
26
# File 'lib/drb_queue/configuration.rb', line 24

def immediate!
  self.immediate = true
end

#on_error(&block) ⇒ Object



28
29
30
# File 'lib/drb_queue/configuration.rb', line 28

def on_error(&block)
  self.error_handler = block
end

#server_uriObject



48
49
50
# File 'lib/drb_queue/configuration.rb', line 48

def server_uri
  "drbunix:#{socket_location}"
end

#store(klass, options = {}) ⇒ Object



12
13
14
15
16
# File 'lib/drb_queue/configuration.rb', line 12

def store(klass, options = {})
  raise "Whoops, that's not a #{DRbQueue::Store}" unless klass <= DRbQueue::Store

  self.persistence_store = [klass, options]
end