Class: Schked::LivenessProbeConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/schked/liveness_probe.rb

Constant Summary collapse

DEFAULTS =
{
  enabled: false,
  bind: "0.0.0.0",
  port: 8080,
  path: "/healthz",
  heartbeat_interval: 5,
  heartbeat_threshold: 15
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ LivenessProbeConfig

Returns a new instance of LivenessProbeConfig.



19
20
21
22
23
24
25
26
27
28
# File 'lib/schked/liveness_probe.rb', line 19

def initialize(attrs = {})
  attrs = DEFAULTS.merge(attrs)

  @enabled = !!attrs[:enabled]
  @bind = validate_bind(attrs[:bind])
  @port = validate_port(attrs[:port])
  @path = validate_path(attrs[:path])
  @heartbeat_interval = validate_positive_integer(attrs[:heartbeat_interval], :heartbeat_interval)
  @heartbeat_threshold = validate_threshold(attrs[:heartbeat_threshold], attrs[:heartbeat_interval])
end

Instance Attribute Details

#bindObject (readonly)

Returns the value of attribute bind.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def bind
  @bind
end

#enabledObject (readonly)

Returns the value of attribute enabled.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def enabled
  @enabled
end

#heartbeat_intervalObject (readonly)

Returns the value of attribute heartbeat_interval.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def heartbeat_interval
  @heartbeat_interval
end

#heartbeat_thresholdObject (readonly)

Returns the value of attribute heartbeat_threshold.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def heartbeat_threshold
  @heartbeat_threshold
end

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/schked/liveness_probe.rb', line 8

def port
  @port
end

Instance Method Details

#to_hObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/schked/liveness_probe.rb', line 30

def to_h
  {
    enabled: enabled,
    bind: bind,
    port: port,
    path: path,
    heartbeat_interval: heartbeat_interval,
    heartbeat_threshold: heartbeat_threshold
  }
end