Class: CFoundry::V1::App::Instance
- Inherits:
-
Object
- Object
- CFoundry::V1::App::Instance
- Defined in:
- lib/cfoundry/v1/app.rb
Overview
Class represnting a running instance of an application.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
The application this instance belongs to.
-
#id ⇒ Object
readonly
Application instance number.
Instance Method Summary collapse
-
#console ⇒ Object
Instance console data.
-
#debugger ⇒ Object
Instance debugger data.
- #file(*path) ⇒ Object
- #files(*path) ⇒ Object
-
#healthy? ⇒ Boolean
True if instance is starting or running, false if it’s down or flapping.
-
#initialize(app, id, client, manifest = {}) ⇒ Instance
constructor
Create an Instance object.
-
#inspect ⇒ Object
Show string representing the application instance.
-
#since ⇒ Object
Instance start time.
-
#state ⇒ Object
(also: #status)
Instance state.
Constructor Details
#initialize(app, id, client, manifest = {}) ⇒ Instance
Create an Instance object.
You’ll usually call App#instances instead
294 295 296 297 298 299 |
# File 'lib/cfoundry/v1/app.rb', line 294 def initialize(app, id, client, manifest = {}) @app = app @id = id @client = client @manifest = manifest end |
Instance Attribute Details
#app ⇒ Object (readonly)
The application this instance belongs to.
286 287 288 |
# File 'lib/cfoundry/v1/app.rb', line 286 def app @app end |
#id ⇒ Object (readonly)
Application instance number.
289 290 291 |
# File 'lib/cfoundry/v1/app.rb', line 289 def id @id end |
Instance Method Details
#console ⇒ Object
Instance console data. If instance has a console, returns a hash containing :ip and :port keys.
329 330 331 332 333 334 335 |
# File 'lib/cfoundry/v1/app.rb', line 329 def console return unless @manifest[:console_ip] and @manifest[:console_port] { :ip => @manifest[:console_ip], :port => @manifest[:console_port] } end |
#debugger ⇒ Object
Instance debugger data. If instance is in debug mode, returns a hash containing :ip and :port keys.
319 320 321 322 323 324 325 |
# File 'lib/cfoundry/v1/app.rb', line 319 def debugger return unless @manifest[:debug_ip] and @manifest[:debug_port] { :ip => @manifest[:debug_ip], :port => @manifest[:debug_port] } end |
#file(*path) ⇒ Object
354 355 356 |
# File 'lib/cfoundry/v1/app.rb', line 354 def file(*path) @client.base.files(@app.name, @id, *path) end |
#files(*path) ⇒ Object
348 349 350 351 352 |
# File 'lib/cfoundry/v1/app.rb', line 348 def files(*path) @client.base.files(@app.name, @id, *path).split("\n").collect do |entry| path + [entry.split(/\s+/, 2)[0]] end end |
#healthy? ⇒ Boolean
True if instance is starting or running, false if it’s down or flapping.
339 340 341 342 343 344 345 346 |
# File 'lib/cfoundry/v1/app.rb', line 339 def healthy? case state when "STARTING", "RUNNING" true when "DOWN", "FLAPPING" false end end |
#inspect ⇒ Object
Show string representing the application instance.
302 303 304 |
# File 'lib/cfoundry/v1/app.rb', line 302 def inspect "#<App::Instance '#{@app.name}' \##@id>" end |
#since ⇒ Object
Instance start time.
313 314 315 |
# File 'lib/cfoundry/v1/app.rb', line 313 def since Time.at(@manifest[:since]) end |
#state ⇒ Object Also known as: status
Instance state.
307 308 309 |
# File 'lib/cfoundry/v1/app.rb', line 307 def state @manifest[:state] end |