Class: Capistrano::DataPlaneApi::Deploy::ServerStats

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(server_name, backend_name) ⇒ ServerStats

Returns a new instance of ServerStats.

Parameters:

  • server_name (String)
  • backend_name (String)


32
33
34
35
36
37
38
39
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 32

def initialize(server_name, backend_name)
  @server_name = server_name
  @backend_name = backend_name
  @success = nil
  @seconds = nil
  @admin_state = 'unknown'
  @operational_state = 'unknown'
end

Instance Attribute Details

#admin_stateString?

Returns:

  • (String, nil)


25
26
27
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 25

def admin_state
  @admin_state
end

#backend_nameString

Returns:

  • (String)


22
23
24
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 22

def backend_name
  @backend_name
end

#end_timeTime?

Returns:

  • (Time, nil)


16
17
18
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 16

def end_time
  @end_time
end

#operational_stateString?

Returns:

  • (String, nil)


28
29
30
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 28

def operational_state
  @operational_state
end

#server_nameString

Returns:

  • (String)


19
20
21
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 19

def server_name
  @server_name
end

#start_timeTime?

Returns:

  • (Time, nil)


13
14
15
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 13

def start_time
  @start_time
end

#successBoolean?

Returns ‘nil` when the deployment hasn’t begun ‘true` when it has finished successfully, `false` when it has failed.

Returns:

  • (Boolean, nil)

    ‘nil` when the deployment hasn’t begun ‘true` when it has finished successfully, `false` when it has failed



10
11
12
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 10

def success
  @success
end

Instance Method Details

#secondsInteger?

Returns How much time has the deployment taken.

Returns:

  • (Integer, nil)

    How much time has the deployment taken



54
55
56
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 54

def seconds
  @seconds ||= Helper.seconds_since(@start_time, to: @end_time)
end

#to_sString

Returns:

  • (String)


42
43
44
45
46
47
48
49
50
51
# File 'lib/capistrano/data_plane_api/deploy/server_stats.rb', line 42

def to_s
  time_string =
    case @success
    when nil    then 'skipped'
    when false  then "failed after #{Helper.humanize_time(seconds)}"
    when true   then "took #{Helper.humanize_time(seconds)}"
    end

  "  #{state_emoji} #{server_title} #{time_string}#{haproxy_states}"
end