Class: Dizby::Service
- Inherits:
-
Object
- Object
- Dizby::Service
- Defined in:
- lib/dizby/service.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ idconv: IdConverter, argc_limit: 256, load_limit: 256 * 1024 * 100, tcp_acl: nil }
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #close
- #connect_to(uri)
-
#initialize(uri = '', front = nil, config = {}) ⇒ Service
constructor
A new instance of Service.
- #server=(srvr) private
- #spawn_on(command, uri)
- #wait
Constructor Details
#initialize(uri = '', front = nil, config = {}) ⇒ Service
Returns a new instance of Service.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dizby/service.rb', line 11 def initialize(uri = '', front = nil, config = {}) config = DEFAULT_CONFIG.merge(config) self.server = ProtocolManager.open_server(uri, front, config) rescue NonAcceptingServer => err # This is to allow servers that don't accept connections # Not all servers will allow connections back to them, so don't allow it self.server = err.server @server.log.warn('using a server that does not allow connections') else @worker = ServiceWorker.new(@server) ensure Dizby.register_server(@server) end |
Instance Method Details
#alive? ⇒ Boolean
40 41 42 |
# File 'lib/dizby/service.rb', line 40 def alive? @server.alive? end |
#close
34 35 36 37 38 |
# File 'lib/dizby/service.rb', line 34 def close Dizby.unregister_server @server return unless alive? @server.shutdown end |
#connect_to(uri)
26 27 28 |
# File 'lib/dizby/service.rb', line 26 def connect_to(uri) ObjectProxy.new(*@server.connect_to(uri)) end |
#server=(srvr) (private)
57 58 59 60 |
# File 'lib/dizby/service.rb', line 57 def server=(srvr) fail DistributedError, 'server could not be opened' unless srvr @server = srvr end |
#spawn_on(command, uri)
30 31 32 |
# File 'lib/dizby/service.rb', line 30 def spawn_on(command, uri) ObjectProxy.new(*@server.spawn_on(command, uri)) end |
#wait
44 45 46 |
# File 'lib/dizby/service.rb', line 44 def wait @worker.join if @worker end |