Class: Vedeu::Distributed::Server Private
- Inherits:
-
Object
- Object
- Vedeu::Distributed::Server
- Includes:
- Singleton
- Defined in:
- lib/vedeu/distributed/server.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 server side of the DRb server/client relationship.
Instance Attribute Summary collapse
- #configuration ⇒ Vedeu::Configuration readonly protected private
Class Method Summary collapse
- .drb_restart ⇒ void private
- .drb_start ⇒ void private
- .drb_status ⇒ Symbol private
- .drb_stop ⇒ void private
- .input(data, type = :key) ⇒ Object private
- .output ⇒ void private
- .restart ⇒ void private
- .shutdown ⇒ void private
- .start ⇒ void private
- .status ⇒ Symbol private
- .stop ⇒ void private
Instance Method Summary collapse
- #drb_running? ⇒ |NilClass private private
- #input(data, type = :keypress) ⇒ void (also: #read) private
- #log(message) ⇒ void private private
- #not_enabled ⇒ Symbol private private
- #output ⇒ void (also: #write) private
-
#pid ⇒ Fixnum
private
The PID of the currently running application.
-
#restart ⇒ void
private
Restart the DRb server.
-
#shutdown ⇒ void
private
When called will stop the DRb server and attempt to terminate the client application.
-
#start ⇒ Vedeu::Distributed::Server
private
Start the DRb server.
-
#status ⇒ Symbol
private
Fetch the status of the DRb server.
-
#stop ⇒ void
private
Stop the DRb server.
- #uri ⇒ String private private
Instance Attribute Details
#configuration ⇒ Vedeu::Configuration (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.
213 214 215 |
# File 'lib/vedeu/distributed/server.rb', line 213 def configuration @configuration end |
Class Method Details
.drb_restart ⇒ void
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.
40 41 42 |
# File 'lib/vedeu/distributed/server.rb', line 40 def restart instance.restart end |
.drb_start ⇒ void
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.
53 54 55 |
# File 'lib/vedeu/distributed/server.rb', line 53 def start instance.start end |
.drb_status ⇒ 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.
60 61 62 |
# File 'lib/vedeu/distributed/server.rb', line 60 def status instance.status end |
.drb_stop ⇒ void
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.
67 68 69 |
# File 'lib/vedeu/distributed/server.rb', line 67 def stop instance.stop end |
.input(data, type = :key) ⇒ 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.
25 26 27 |
# File 'lib/vedeu/distributed/server.rb', line 25 def input(data, type = :key) instance.input(data, type) end |
.output ⇒ void
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.
31 32 33 |
# File 'lib/vedeu/distributed/server.rb', line 31 def output instance.output end |
.restart ⇒ void
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.
37 38 39 |
# File 'lib/vedeu/distributed/server.rb', line 37 def restart instance.restart end |
.shutdown ⇒ void
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.
44 45 46 |
# File 'lib/vedeu/distributed/server.rb', line 44 def shutdown instance.shutdown end |
.start ⇒ void
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.
50 51 52 |
# File 'lib/vedeu/distributed/server.rb', line 50 def start instance.start end |
.status ⇒ 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.
57 58 59 |
# File 'lib/vedeu/distributed/server.rb', line 57 def status instance.status end |
.stop ⇒ void
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.
64 65 66 |
# File 'lib/vedeu/distributed/server.rb', line 64 def stop instance.stop end |
Instance Method Details
#drb_running? ⇒ |NilClass (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.
218 219 220 |
# File 'lib/vedeu/distributed/server.rb', line 218 def drb_running? DRb.thread end |
#input(data, type = :keypress) ⇒ void 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.
This method returns an undefined value.
77 78 79 |
# File 'lib/vedeu/distributed/server.rb', line 77 def input(data, type = :keypress) Vedeu.trigger(:_drb_input_, data, type) end |
#log(message) ⇒ 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.
223 224 225 |
# File 'lib/vedeu/distributed/server.rb', line 223 def log() Vedeu.log(type: :drb, message: "#{}: '#{uri}'") end |
#not_enabled ⇒ 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.
228 229 230 231 232 |
# File 'lib/vedeu/distributed/server.rb', line 228 def not_enabled log('Not enabled') :drb_not_enabled end |
#output ⇒ void 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.
This method returns an undefined value.
83 84 85 |
# File 'lib/vedeu/distributed/server.rb', line 83 def output Vedeu.trigger(:_drb_retrieve_output_) end |
#pid ⇒ Fixnum
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 The PID of the currently running application.
89 90 91 |
# File 'lib/vedeu/distributed/server.rb', line 89 def pid Process.pid end |
#restart ⇒ void
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.
Restart the DRb server.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/vedeu/distributed/server.rb', line 99 def restart log('Attempting to restart') return not_enabled unless Vedeu.config.drb? if drb_running? log('Restarting') stop else log('Not running') end start end |
#shutdown ⇒ void
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.
:exit never gets triggered as when the DRb server goes away, no further methods will be called.
This method returns an undefined value.
When called will stop the DRb server and attempt to terminate the client application.
125 126 127 128 129 130 131 132 133 |
# File 'lib/vedeu/distributed/server.rb', line 125 def shutdown return not_enabled unless Vedeu.config.drb? stop if drb_running? Vedeu.trigger(:_exit_) Vedeu::Terminal.restore_screen end |
#start ⇒ Vedeu::Distributed::Server
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.
Start the DRb server.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/vedeu/distributed/server.rb', line 141 def start log('Attempting to start') return not_enabled unless Vedeu.config.drb? if drb_running? log('Already started') else log('Starting') DRb.start_service(uri, self) # DRb.thread.join # not convinced this is needed here end end |
#status ⇒ 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.
Fetch the status of the DRb server.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/vedeu/distributed/server.rb', line 164 def status log('Fetching status') return not_enabled unless Vedeu.config.drb? if drb_running? log('Running') :running else log('Stopped') :stopped end end |
#stop ⇒ void
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.
Stop the DRb server.
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/vedeu/distributed/server.rb', line 188 def stop log('Attempting to stop') return not_enabled unless Vedeu.config.drb? if drb_running? log('Stopping') DRb.stop_service DRb.thread.join else log('Already stopped') end rescue NoMethodError # raised when #join is called on NilClass. Vedeu.log(type: :drb, message: 'Attempted to #join on DRb.thread.') end |
#uri ⇒ String (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.
235 236 237 238 |
# File 'lib/vedeu/distributed/server.rb', line 235 def uri Vedeu::Distributed::Uri.new(Vedeu.config.drb_host, Vedeu.config.drb_port).to_s end |