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



112
113
114
# File 'lib/kumonos/envoy.rb', line 112

def access_log_path
  @access_log_path
end

#additional_http_filtersObject

Returns the value of attribute additional_http_filters

Returns:

  • (Object)

    the current value of additional_http_filters



112
113
114
# File 'lib/kumonos/envoy.rb', line 112

def additional_http_filters
  @additional_http_filters
end

#addressObject

Returns the value of attribute address

Returns:

  • (Object)

    the current value of address



112
113
114
# File 'lib/kumonos/envoy.rb', line 112

def address
  @address
end

#discovery_serviceObject

Returns the value of attribute discovery_service

Returns:

  • (Object)

    the current value of discovery_service



112
113
114
# File 'lib/kumonos/envoy.rb', line 112

def discovery_service
  @discovery_service
end

Class Method Details

.build(h, discovery_service) ⇒ Object



114
115
116
117
# File 'lib/kumonos/envoy.rb', line 114

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

Instance Method Details

#to_hObject



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
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/kumonos/envoy.rb', line 120

def to_h
  h = super
  h.delete(:discovery_service)
  h.delete(:access_log_path)
  h.delete(:additional_http_filters)

  http_filters = (additional_http_filters || []) + DEFAULT_HTTP_FILTERS

  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: http_filters
          }
        }
      ]
    }
  ]
  h
end