Class: Capistrano::DataPlaneApi::Deploy::ServerStats
- Inherits:
-
Object
- Object
- Capistrano::DataPlaneApi::Deploy::ServerStats
- Defined in:
- lib/capistrano/data_plane_api/deploy/server_stats.rb
Overview
Represents the stats of a deployment to a particular server
Instance Attribute Summary collapse
- #admin_state ⇒ Object
- #backend_name ⇒ Object
- #end_time ⇒ Object
- #operational_state ⇒ Object
- #server_name ⇒ Object
- #start_time ⇒ Object
-
#state ⇒ Object
nilwhen the deployment hasn't beguntruewhen it has finished successfully,falsewhen it has failed.
Instance Method Summary collapse
-
#initialize(server_name, backend_name, state: :pending, admin_state: 'unknown', operational_state: 'unknown') ⇒ ServerStats
constructor
A new instance of ServerStats.
-
#seconds ⇒ Object
How much time has the deployment taken.
- #to_s ⇒ Object
Constructor Details
#initialize(server_name, backend_name, state: :pending, admin_state: 'unknown', operational_state: 'unknown') ⇒ ServerStats
Returns a new instance of ServerStats.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 34 def initialize( server_name, backend_name, state: :pending, admin_state: 'unknown', operational_state: 'unknown' ) @server_name = server_name @backend_name = backend_name @state = state @admin_state = admin_state @operational_state = operational_state @seconds = nil #: Integer? end |
Instance Attribute Details
#admin_state ⇒ Object
28 29 30 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 28 def admin_state @admin_state end |
#backend_name ⇒ Object
25 26 27 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 25 def backend_name @backend_name end |
#end_time ⇒ Object
19 20 21 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 19 def end_time @end_time end |
#operational_state ⇒ Object
31 32 33 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 31 def operational_state @operational_state end |
#server_name ⇒ Object
22 23 24 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 22 def server_name @server_name end |
#start_time ⇒ Object
16 17 18 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 16 def start_time @start_time end |
#state ⇒ Object
nil when the deployment hasn't begun
true when it has finished successfully, false when it has failed
13 14 15 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 13 def state @state end |
Instance Method Details
#seconds ⇒ Object
How much time has the deployment taken
65 66 67 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 65 def seconds @seconds ||= Helper.seconds_since(T.must(@start_time), to: T.must(@end_time)) end |
#to_s ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 50 def to_s time_string = case @state when :pending then 'skipped' when :failed then "failed after #{Helper.humanize_time(T.must(seconds))}" when :success then "took #{Helper.humanize_time(T.must(seconds))}" when :info then "at #{Time.now}" end " #{state_emoji} #{server_title} #{time_string}#{haproxy_states}" end |