Class: Kumonos::Envoy::EnvoyConfig

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adminObject

Returns the value of attribute admin



10
11
12
# File 'lib/kumonos/envoy.rb', line 10

def admin
  @admin
end

#dsObject

Returns the value of attribute ds



10
11
12
# File 'lib/kumonos/envoy.rb', line 10

def ds
  @ds
end

#listenerObject

Returns the value of attribute listener



10
11
12
# File 'lib/kumonos/envoy.rb', line 10

def listener
  @listener
end

#statsdObject

Returns the value of attribute statsd



10
11
12
# File 'lib/kumonos/envoy.rb', line 10

def statsd
  @statsd
end

#versionObject

Returns the value of attribute version



10
11
12
# File 'lib/kumonos/envoy.rb', line 10

def version
  @version
end

Class Method Details

.build(h) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/kumonos/envoy.rb', line 12

def build(h)
  ds = DiscoverService.build(h.fetch('ds'))
  new(
    h.fetch('version'),
    ds,
    h['statsd'] ? Cluster.build(h['statsd']) : nil,
    Listener.build(h.fetch('listener'), ds),
    Admin.build(h.fetch('admin'))
  )
end

Instance Method Details

#to_hObject



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

def to_h
  h = super
  h.delete(:version)
  h.delete(:ds)
  h.delete(:statsd)
  h.delete(:listener)
  h[:admin] = admin.to_h
  h[:listeners] = [listener.to_h]
  h[:cluster_manager] = { cds: ds.to_h, clusters: [] }

  if statsd
    h[:statsd_tcp_cluster_name] = statsd.name
    h[:cluster_manager][:clusters] << statsd.to_h
  end

  h
end