module Kumonos

Kumonos

Constants

ALLOWED_METHODS
CircuitBreaker
DEFAULT_ROUTE_NAME
Listener
Route
VERSION

Public Instance Methods

to_h() click to toggle source
Calls superclass method
# 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
to_h_with_retry() click to toggle source
# File lib/kumonos/routes.rb, line 82
def to_h_with_retry
  h = to_h
  h[:retry_policy] = retry_policy.to_h if retry_policy

  if method
    m = method.upcase
    raise "method must be one of #{ALLOWED_METHODS.join(',')}: given `#{m}`" unless ALLOWED_METHODS.include?(m)

    h[:headers] = [{ name: ':method', value: m, regex: false }]
  else
    h[:headers] = [{ name: ':method', value: '(GET|HEAD)', regex: true }]
  end

  h
end