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
: String.
-
#backend_name ⇒ Object
: String.
-
#end_time ⇒ Object
: Time?.
-
#operational_state ⇒ Object
: String.
-
#server_name ⇒ Object
: String.
-
#start_time ⇒ Object
: Time?.
-
#state ⇒ Object
‘nil` when the deployment hasn’t begun ‘true` when it has finished successfully, `false` when it has failed.
Instance Method Summary collapse
-
#initialize(server_name, backend_name, state: :pending, admin_state: 'unknown', operational_state: 'unknown') ⇒ ServerStats
constructor
: (String, String, Symbol, String, String) -> void.
-
#seconds ⇒ Object
How much time has the deployment taken.
-
#to_s ⇒ Object
: -> String.
Constructor Details
#initialize(server_name, backend_name, state: :pending, admin_state: 'unknown', operational_state: 'unknown') ⇒ ServerStats
: (String, String, Symbol, String, String) -> void
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 = T.let(nil, T.nilable(Integer)) end |
Instance Attribute Details
#admin_state ⇒ Object
: String
28 29 30 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 28 def admin_state @admin_state end |
#backend_name ⇒ Object
: String
25 26 27 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 25 def backend_name @backend_name end |
#end_time ⇒ Object
: Time?
19 20 21 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 19 def end_time @end_time end |
#operational_state ⇒ Object
: String
31 32 33 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 31 def operational_state @operational_state end |
#server_name ⇒ Object
: String
22 23 24 |
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 22 def server_name @server_name end |
#start_time ⇒ Object
: Time?
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
: Symbol
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
: -> Integer?
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
: -> String
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 |