Class: Kumonos::Routes::Route

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

#clusterObject

Returns the value of attribute cluster



29
30
31
# File 'lib/kumonos/routes.rb', line 29

def cluster
  @cluster
end

#prefixObject

Returns the value of attribute prefix



29
30
31
# File 'lib/kumonos/routes.rb', line 29

def prefix
  @prefix
end

#retry_policyObject

Returns the value of attribute retry_policy



29
30
31
# File 'lib/kumonos/routes.rb', line 29

def retry_policy
  @retry_policy
end

#timeout_msObject

Returns the value of attribute timeout_ms



29
30
31
# File 'lib/kumonos/routes.rb', line 29

def timeout_ms
  @timeout_ms
end

Class Method Details

.build(h, cluster) ⇒ Object



31
32
33
# File 'lib/kumonos/routes.rb', line 31

def build(h, cluster)
  new(h.fetch('prefix'), cluster, h.fetch('timeout_ms'), RetryPolicy.build(h.fetch('retry_policy')))
end

Instance Method Details

#to_hObject



36
37
38
39
40
41
# File 'lib/kumonos/routes.rb', line 36

def to_h
  h = super
  h.delete(:retry_policy)
  h[:auto_host_rewrite] = true
  h
end

#to_h_with_retryObject



43
44
45
46
47
48
# File 'lib/kumonos/routes.rb', line 43

def to_h_with_retry
  h = to_h
  h[:retry_policy] = retry_policy.to_h
  h[:headers] = [{ name: ':method', value: '(GET|HEAD)', regex: true }]
  h
end