class Dizby::Service
Constants
- DEFAULT_CONFIG
Public Class Methods
new(uri: '', front: nil, **config)
click to toggle source
# File lib/dizby/service.rb, line 14 def initialize(uri: '', front: nil, **config) config = DEFAULT_CONFIG.merge(config) args = ServerArguments.new(uri, front, config) self.server = ProtocolManager.open_server(args) 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
Public Instance Methods
alive?()
click to toggle source
# File lib/dizby/service.rb, line 46 def alive? @server.alive? end
close()
click to toggle source
# File lib/dizby/service.rb, line 40 def close Dizby.unregister_server @server return unless alive? @server.shutdown end
connect_to(uri:, **options)
click to toggle source
# File lib/dizby/service.rb, line 30 def connect_to(uri:, **options) args = ClientArguments.new(uri, options) ObjectProxy.new(*@server.connect_to(args)) end
spawn_on(uri:, command:, **options)
click to toggle source
# File lib/dizby/service.rb, line 35 def spawn_on(uri:, command:, **options) args = SpawnArguments.new(uri, command, options) ObjectProxy.new(*@server.spawn_on(args)) end
wait()
click to toggle source
# File lib/dizby/service.rb, line 50 def wait @worker.join if @worker end
Private Instance Methods
server=(srvr)
click to toggle source
# File lib/dizby/service.rb, line 63 def server=(srvr) raise DistributedError, 'server could not be opened' unless srvr @server = srvr end