Class: Kumonos::Clusters::Cluster
- Inherits:
-
Struct
- Object
- Struct
- Kumonos::Clusters::Cluster
- Defined in:
- lib/kumonos/clusters.rb
Instance Attribute Summary collapse
-
#circuit_breaker ⇒ Object
Returns the value of attribute circuit_breaker.
-
#connect_timeout_ms ⇒ Object
Returns the value of attribute connect_timeout_ms.
-
#lb ⇒ Object
Returns the value of attribute lb.
-
#name ⇒ Object
Returns the value of attribute name.
-
#outlier_detection ⇒ Object
Returns the value of attribute outlier_detection.
-
#tls ⇒ Object
Returns the value of attribute tls.
-
#use_sds ⇒ Object
Returns the value of attribute use_sds.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#circuit_breaker ⇒ Object
Returns the value of attribute circuit_breaker
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def circuit_breaker @circuit_breaker end |
#connect_timeout_ms ⇒ Object
Returns the value of attribute connect_timeout_ms
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def connect_timeout_ms @connect_timeout_ms end |
#lb ⇒ Object
Returns the value of attribute lb
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def lb @lb end |
#name ⇒ Object
Returns the value of attribute name
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def name @name end |
#outlier_detection ⇒ Object
Returns the value of attribute outlier_detection
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def outlier_detection @outlier_detection end |
#tls ⇒ Object
Returns the value of attribute tls
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def tls @tls end |
#use_sds ⇒ Object
Returns the value of attribute use_sds
14 15 16 |
# File 'lib/kumonos/clusters.rb', line 14 def use_sds @use_sds end |
Class Method Details
.build(h) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kumonos/clusters.rb', line 16 def build(h) use_sds = h.fetch('sds', false) lb = use_sds ? nil : h.fetch('lb') raise "Invalid format in `lb` value. Must be \"${host}:${port}\" format: #{lb}" if lb && lb.split(':').size != 2 circuit_breaker = if h.key?('circuit_breaker') CircuitBreaker.build(h.fetch('circuit_breaker')) else nil end new( h.fetch('cluster_name'), h.fetch('connect_timeout_ms'), lb, h.fetch('tls'), circuit_breaker, OutlierDetection.build(h['outlier_detection']), # optional use_sds ) end |
Instance Method Details
#to_h ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/kumonos/clusters.rb', line 40 def to_h h = super h.delete(:lb) h.delete(:use_sds) if use_sds h[:type] = 'sds' h[:service_name] = name h[:features] = 'http2' else h[:type] = 'strict_dns' h[:hosts] = [{ url: "tcp://#{lb}" }] end h[:lb_type] = 'round_robin' h.delete(:tls) if tls h[:ssl_context] = {} h[:ssl_context][:sni] = lb.split(':', 2)[0] unless use_sds end h.delete(:circuit_breaker) h[:circuit_breakers] = { default: circuit_breaker.to_h } if circuit_breaker if outlier_detection h[:outlier_detection] = outlier_detection.to_h else h.delete(:outlier_detection) end h end |