Class: Bullring::ServerWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/bullring/util/server_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ ServerWrapper

Returns a new instance of ServerWrapper.



35
36
37
38
# File 'lib/bullring/util/server_registry.rb', line 35

def initialize(uri)
  @uri = uri
  @server = DRbObject.new_with_uri(uri)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/bullring/util/server_registry.rb', line 40

def method_missing(m, *args, &block)  
  begin
    @server.send(m, *args, &block)
  rescue DRb::DRbConnError, Errno::ECONNREFUSED => e
    Bullring.logger.debug {"Lost connection to the server at #{@uri}"}
    raise ServerOffline, "The connection to the server at #{@uri} was lost"
  end
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



33
34
35
# File 'lib/bullring/util/server_registry.rb', line 33

def server
  @server
end