Class: Kumonos::Routes::Vhost

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#domainsObject

Returns the value of attribute domains

Returns:

  • (Object)

    the current value of domains



15
16
17
# File 'lib/kumonos/routes.rb', line 15

def domains
  @domains
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



15
16
17
# File 'lib/kumonos/routes.rb', line 15

def name
  @name
end

#routesObject

Returns the value of attribute routes

Returns:

  • (Object)

    the current value of routes



15
16
17
# File 'lib/kumonos/routes.rb', line 15

def routes
  @routes
end

Class Method Details

.build(h) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/kumonos/routes.rb', line 17

def build(h)
  name = h.fetch('name')
  cluster_name = h.fetch('cluster_name')
  host_header = h['host_header']
  routes = h.fetch('routes').map { |r| Route.build(r, cluster_name, host_header) }
  new(name, [name], routes)
end

Instance Method Details

#to_hObject



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

def to_h
  h = super
  h[:routes] = routes.flat_map do |r|
    if r.retry_policy.nil?
      [r.to_h]
    # i.e. retry with gRPC request (HTTP POST)
    elsif r.method
      [r.to_h_with_retry]
    else
      [r.to_h_with_retry, r.to_h]
    end
  end
  h
end