Class: Kumonos::Clusters::Cluster

Inherits:
Struct
  • Object
show all
Defined in:
lib/kumonos/clusters.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#circuit_breakerObject

Returns the value of attribute circuit_breaker

Returns:

  • (Object)

    the current value of circuit_breaker



12
13
14
# File 'lib/kumonos/clusters.rb', line 12

def circuit_breaker
  @circuit_breaker
end

#connect_timeout_msObject

Returns the value of attribute connect_timeout_ms

Returns:

  • (Object)

    the current value of connect_timeout_ms



12
13
14
# File 'lib/kumonos/clusters.rb', line 12

def connect_timeout_ms
  @connect_timeout_ms
end

#lbObject

Returns the value of attribute lb

Returns:

  • (Object)

    the current value of lb



12
13
14
# File 'lib/kumonos/clusters.rb', line 12

def lb
  @lb
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



12
13
14
# File 'lib/kumonos/clusters.rb', line 12

def name
  @name
end

#tlsObject

Returns the value of attribute tls

Returns:

  • (Object)

    the current value of tls



12
13
14
# File 'lib/kumonos/clusters.rb', line 12

def tls
  @tls
end

Class Method Details

.build(h) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/kumonos/clusters.rb', line 14

def build(h)
  new(
    h.fetch('name'),
    h.fetch('connect_timeout_ms'),
    h.fetch('lb'),
    h.fetch('tls'),
    CircuitBreaker.build(h.fetch('circuit_breaker'))
  )
end

Instance Method Details

#to_hObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/kumonos/clusters.rb', line 25

def to_h
  h = super

  h.delete(:lb)
  h[:type] = 'strict_dns'
  h[:lb_type] = 'round_robin'
  h[:hosts] = [{ url: "tcp://#{lb}" }]

  h.delete(:tls)
  h[:ssl_context] = {} if tls

  h.delete(:circuit_breaker)
  h[:circuit_breakers] = { default: circuit_breaker.to_h }

  h
end