Class: CFoundry::App::Instance
- Inherits:
-
Object
- Object
- CFoundry::App::Instance
- Defined in:
- lib/cfoundry/app.rb
Overview
Class represnting a running instance of an application.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
The application this instance belongs to.
-
#index ⇒ Object
readonly
Application instance number.
Instance Method Summary collapse
-
#console ⇒ Object
Instance console data.
-
#debugger ⇒ Object
Instance debugger data.
-
#file(*path) ⇒ Object
Retrieve file contents for this instance.
-
#files(*path) ⇒ Object
Retrieve file listing under path for this instance.
-
#healthy? ⇒ Boolean
True if instance is starting or running, false if it’s down or flapping.
-
#initialize(appname, index, client, manifest = {}) ⇒ Instance
constructor
Create an Instance object.
-
#inspect ⇒ Object
:nodoc:.
-
#since ⇒ Object
Instance start time.
-
#state ⇒ Object
(also: #status)
Instance state.
Constructor Details
#initialize(appname, index, client, manifest = {}) ⇒ Instance
Create an Instance object.
You’ll usually call App#instances instead
476 477 478 479 480 481 |
# File 'lib/cfoundry/app.rb', line 476 def initialize(appname, index, client, manifest = {}) @app = appname @index = index @client = client @manifest = manifest end |
Instance Attribute Details
#app ⇒ Object (readonly)
The application this instance belongs to.
468 469 470 |
# File 'lib/cfoundry/app.rb', line 468 def app @app end |
#index ⇒ Object (readonly)
Application instance number.
471 472 473 |
# File 'lib/cfoundry/app.rb', line 471 def index @index end |
Instance Method Details
#console ⇒ Object
Instance console data. If instance has a console, returns a hash containing :ip and :port keys.
510 511 512 513 514 515 516 |
# File 'lib/cfoundry/app.rb', line 510 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.
500 501 502 503 504 505 506 |
# File 'lib/cfoundry/app.rb', line 500 def debugger return unless @manifest["debug_ip"] and @manifest["debug_port"] { :ip => @manifest["debug_ip"], :port => @manifest["debug_port"] } end |
#file(*path) ⇒ Object
Retrieve file contents for this instance.
- path
-
A sequence of strings representing path segments.
For example,
files("foo", "bar")
forfoo/bar
.
547 548 549 |
# File 'lib/cfoundry/app.rb', line 547 def file(*path) @client.rest.files(@app, @index, *path) end |
#files(*path) ⇒ Object
Retrieve file listing under path for this instance.
- path
-
A sequence of strings representing path segments.
For example,
files("foo", "bar")
forfoo/bar
.
535 536 537 538 539 |
# File 'lib/cfoundry/app.rb', line 535 def files(*path) @client.rest.files(@app, @index, *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.
520 521 522 523 524 525 526 527 |
# File 'lib/cfoundry/app.rb', line 520 def healthy? case state when "STARTING", "RUNNING" true when "DOWN", "FLAPPING" false end end |
#inspect ⇒ Object
:nodoc:
483 484 485 |
# File 'lib/cfoundry/app.rb', line 483 def inspect # :nodoc: "#<App::Instance '#@app' \##@index>" end |
#since ⇒ Object
Instance start time.
494 495 496 |
# File 'lib/cfoundry/app.rb', line 494 def since Time.at(@manifest["since"]) end |
#state ⇒ Object Also known as: status
Instance state.
488 489 490 |
# File 'lib/cfoundry/app.rb', line 488 def state @manifest["state"] end |