Class: Kumonos::Envoy::Cluster
- Inherits:
-
Struct
- Object
- Struct
- Kumonos::Envoy::Cluster
- Defined in:
- lib/kumonos/envoy.rb
Constant Summary collapse
- ONE_SECONDS_IN_NANOS =
1_000_000_000
- ONE_MSEC_IN_NANOS =
1_000_000
Instance Attribute Summary collapse
-
#connect_timeout_ms ⇒ Object
Returns the value of attribute connect_timeout_ms.
-
#hosts ⇒ Object
Returns the value of attribute hosts.
-
#lb_type ⇒ Object
Returns the value of attribute lb_type.
-
#name ⇒ Object
Returns the value of attribute name.
-
#tls ⇒ Object
Returns the value of attribute tls.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#connect_timeout_ms ⇒ Object
Returns the value of attribute connect_timeout_ms
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def connect_timeout_ms @connect_timeout_ms end |
#hosts ⇒ Object
Returns the value of attribute hosts
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def hosts @hosts end |
#lb_type ⇒ Object
Returns the value of attribute lb_type
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def lb_type @lb_type end |
#name ⇒ Object
Returns the value of attribute name
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def name @name end |
#tls ⇒ Object
Returns the value of attribute tls
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def tls @tls end |
#type ⇒ Object
Returns the value of attribute type
190 191 192 |
# File 'lib/kumonos/envoy.rb', line 190 def type @type end |
Class Method Details
.build(h) ⇒ Object
192 193 194 195 |
# File 'lib/kumonos/envoy.rb', line 192 def build(h) new(h.fetch('name'), h.fetch('type'), h.fetch('tls'), h.fetch('connect_timeout_ms'), h.fetch('lb_type'), h.fetch('hosts')) end |
Instance Method Details
#to_h ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/kumonos/envoy.rb', line 200 def to_h h = super h[:type] = type.upcase h.delete(:lb_type) h[:lb_policy] = lb_type.upcase h.delete(:tls) h[:tls_context] = {} if tls sec, nanos = (connect_timeout_ms * ONE_MSEC_IN_NANOS).divmod(ONE_SECONDS_IN_NANOS) h.delete(:connect_timeout_ms) h[:connect_timeout] = { seconds: sec, nanos: nanos } # Just work-around, it could be configurable. h[:dns_lookup_family] = 'V4_ONLY' h end |