Class: Vedeu::Distributed::Client Private
- Inherits:
-
Object
- Object
- Vedeu::Distributed::Client
- Defined in:
- lib/vedeu/distributed/client.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A class for the client side of the DRb server/client relationship.
Instance Attribute Summary collapse
- #uri ⇒ String readonly protected private
Class Method Summary collapse
- .connect(uri) ⇒ Object private
Instance Method Summary collapse
-
#connect ⇒ Symbol
private
Simulate connecting to the DRb server by requesting its status.
- #drb_connection_error ⇒ Symbol private private
-
#initialize(uri) ⇒ Vedeu::Distributed::Client
constructor
private
Returns a new instance of Vedeu::Distributed::Client.
-
#input(data) ⇒ void|Symbol
(also: #read)
private
Send input to the DRb server.
-
#output ⇒ void|Symbol
(also: #write)
private
Fetch output from the DRb server.
- #server ⇒ void private private
-
#shutdown ⇒ void|Symbol
private
Shutdown the DRb server and the client application.
Constructor Details
#initialize(uri) ⇒ Vedeu::Distributed::Client
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Vedeu::Distributed::Client.
32 33 34 |
# File 'lib/vedeu/distributed/client.rb', line 32 def initialize(uri) @uri = uri.to_s end |
Instance Attribute Details
#uri ⇒ String (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 |
# File 'lib/vedeu/distributed/client.rb', line 103 def uri @uri end |
Class Method Details
.connect(uri) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/vedeu/distributed/client.rb', line 24 def self.connect(uri) new(uri).connect end |
Instance Method Details
#connect ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Simulate connecting to the DRb server by requesting its status.
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/distributed/client.rb', line 40 def connect server.status rescue DRb::DRbConnError drb_connection_error rescue DRb::DRbBadURI Vedeu.log_stdout(message: 'Could not connect to DRb server, URI may ' \ 'be bad.') :drb_bad_uri end |
#drb_connection_error ⇒ Symbol (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 116 117 |
# File 'lib/vedeu/distributed/client.rb', line 113 def drb_connection_error Vedeu.log_stdout(message: 'Could not connect to DRb server.') :drb_connection_error end |
#input(data) ⇒ void|Symbol Also known as: read
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Send input to the DRb server.
57 58 59 60 61 62 |
# File 'lib/vedeu/distributed/client.rb', line 57 def input(data) server.input(data) rescue DRb::DRbConnError drb_connection_error end |
#output ⇒ void|Symbol Also known as: write
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Fetch output from the DRb server.
68 69 70 71 72 73 |
# File 'lib/vedeu/distributed/client.rb', line 68 def output server.output rescue DRb::DRbConnError drb_connection_error end |
#server ⇒ void (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
108 109 110 |
# File 'lib/vedeu/distributed/client.rb', line 108 def server @server ||= DRbObject.new_with_uri(uri) end |
#shutdown ⇒ void|Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Runtime::Application will raise StopIteration when its ‘.stop` method is called. Here we rescue that to give a clean client exit.
Shutdown the DRb server and the client application.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/vedeu/distributed/client.rb', line 84 def shutdown server.shutdown Process.kill('KILL', server.pid) rescue DRb::DRbConnError drb_connection_error rescue Interrupt Vedeu.log_stdout(message: 'Client application exited.') ensure :shutdown end |