Class: Kumonos::Envoy::Listener

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

#access_log_pathObject

Returns the value of attribute access_log_path

Returns:

  • (Object)

    the current value of access_log_path



105
106
107
# File 'lib/kumonos/envoy.rb', line 105

def access_log_path
  @access_log_path
end

#addressObject

Returns the value of attribute address

Returns:

  • (Object)

    the current value of address



105
106
107
# File 'lib/kumonos/envoy.rb', line 105

def address
  @address
end

#discovery_serviceObject

Returns the value of attribute discovery_service

Returns:

  • (Object)

    the current value of discovery_service



105
106
107
# File 'lib/kumonos/envoy.rb', line 105

def discovery_service
  @discovery_service
end

Class Method Details

.build(h, discovery_service) ⇒ Object



107
108
109
110
# File 'lib/kumonos/envoy.rb', line 107

def build(h, discovery_service)
  address = AddressParser.call(h.fetch('address'))
  new(address, h.fetch('access_log_path'), discovery_service)
end

Instance Method Details

#to_hObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/kumonos/envoy.rb', line 113

def to_h
  h = super
  h.delete(:discovery_service)
  h.delete(:access_log_path)
  h[:name] = 'egress'
  h[:filter_chains] = [
    {
      filters: [
        {
          name: 'envoy.http_connection_manager',
          config: {
            codec_type: 'AUTO',
            stat_prefix: 'egress_http',
            access_log: [
              {
                name: 'envoy.file_access_log',
                config: {
                  path: access_log_path
                }
              }
            ],
            rds: {
              config_source: {
                api_config_source: {
                  cluster_names: [discovery_service.cluster.name],
                  refresh_delay: {
                    seconds: discovery_service.refresh_delay_ms / 1000.0
                  }
                }
              },
              route_config_name: DEFAULT_ROUTE_NAME
            },
            http_filters: [{ name: 'envoy.router' }]
          }
        }
      ]
    }
  ]
  h
end