Class: Kumonos::Envoy::EnvoyConfig
- Inherits:
-
Struct
- Object
- Struct
- Kumonos::Envoy::EnvoyConfig
- Defined in:
- lib/kumonos/envoy.rb
Instance Attribute Summary collapse
-
#admin ⇒ Object
Returns the value of attribute admin.
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#discovery_service ⇒ Object
Returns the value of attribute discovery_service.
-
#listener ⇒ Object
Returns the value of attribute listener.
-
#node ⇒ Object
Returns the value of attribute node.
-
#runtime ⇒ Object
Returns the value of attribute runtime.
-
#sds ⇒ Object
Returns the value of attribute sds.
-
#statsd ⇒ Object
Returns the value of attribute statsd.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#admin ⇒ Object
Returns the value of attribute admin
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def admin @admin end |
#cluster ⇒ Object
Returns the value of attribute cluster
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def cluster @cluster end |
#discovery_service ⇒ Object
Returns the value of attribute discovery_service
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def discovery_service @discovery_service end |
#listener ⇒ Object
Returns the value of attribute listener
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def listener @listener end |
#node ⇒ Object
Returns the value of attribute node
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def node @node end |
#runtime ⇒ Object
Returns the value of attribute runtime
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def runtime @runtime end |
#sds ⇒ Object
Returns the value of attribute sds
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def sds @sds end |
#statsd ⇒ Object
Returns the value of attribute statsd
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def statsd @statsd end |
#version ⇒ Object
Returns the value of attribute version
14 15 16 |
# File 'lib/kumonos/envoy.rb', line 14 def version @version end |
Class Method Details
.build(h, cluster:, node:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/kumonos/envoy.rb', line 16 def build(h, cluster:, node:) discovery_service = DiscoverService.build(h.fetch('discovery_service')) sds = DiscoverService.build(h.fetch('sds')) new( h.fetch('version'), discovery_service, h['statsd'] ? h['statsd'].fetch('address') : nil, Listener.build(h.fetch('listener'), discovery_service), Admin.build(h.fetch('admin')), cluster, node, sds, h['runtime'] ) end |
Instance Method Details
#to_h ⇒ Object
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/kumonos/envoy.rb', line 46 def to_h h = super h.delete(:version) h.delete(:discovery_service) h.delete(:sds) h.delete(:statsd) h.delete(:listener) h.delete(:cluster) h.delete(:node) h.delete(:runtime) h[:admin] = admin.to_h h[:runtime] = runtime.to_h if runtime h[:static_resources] = { listeners: [listener.to_h], clusters: [discovery_service.cluster.to_h, sds.cluster.to_h] } h[:dynamic_resources] = { cds_config: { api_config_source: { cluster_names: [discovery_service.cluster.name], refresh_delay: { seconds: discovery_service.refresh_delay_ms / 1000.0 } } }, deprecated_v1: { sds_config: { api_config_source: { cluster_names: [sds.cluster.name], refresh_delay: { seconds: sds.refresh_delay_ms / 1000.0 } } } } } if statsd statsd_address, statsd_port = statsd.split(':') h[:stats_sinks] = [ { name: 'envoy.dog_statsd', config: { address: { socket_address: { protocol: 'UDP', address: statsd_address, port_value: Integer(statsd_port) } } } } ] h[:stats_config] = { use_all_default_tags: true, stats_tags: [ { tag_name: 'service-cluster', fixed_value: cluster }, { tag_name: 'service-node', fixed_value: node } ] } end h end |