Class: Async::Service::Supervisor::Envoy::Endpoint
- Inherits:
-
Object
- Object
- Async::Service::Supervisor::Envoy::Endpoint
- Defined in:
- lib/async/service/supervisor/envoy/endpoint.rb
Overview
Represents an upstream endpoint published to Envoy EDS.
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#protocols ⇒ Object
readonly
Returns the value of attribute protocols.
-
#scheme ⇒ Object
readonly
Returns the value of attribute scheme.
- #The grouped concrete addresses.(groupedconcreteaddresses.) ⇒ Object readonly
- #The supported upstream HTTP protocol names.(supportedupstreamHTTPprotocolnames.) ⇒ Object readonly
- #The upstream cluster name.(upstreamclustername.) ⇒ Object readonly
Class Method Summary collapse
-
.build(name:, scheme:, protocols:, addresses:) ⇒ Object
Build an immutable endpoint.
-
.wrap(value) ⇒ Object
Wrap serialized endpoint state.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Compare this endpoint with another endpoint by value.
-
#freeze ⇒ Object
Freeze this endpoint and cache its value hash.
-
#hash ⇒ Object
Compute the value hash used when grouping endpoints.
-
#initialize(name, scheme, protocols, addresses) ⇒ Endpoint
constructor
Initialize an endpoint.
- #The upstream application scheme.=(upstreamapplicationscheme. = (value)) ⇒ Object
Constructor Details
#initialize(name, scheme, protocols, addresses) ⇒ Endpoint
Initialize an endpoint.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 46 def initialize(name, scheme, protocols, addresses) @name = name @scheme = scheme @protocols = protocols raise ArgumentError, "An endpoint requires at least one protocol!" if @protocols.empty? @addresses = addresses raise ArgumentError, "An endpoint requires at least one address!" if @addresses.empty? @hash = nil end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
67 68 69 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 67 def addresses @addresses end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
58 59 60 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 58 def name @name end |
#protocols ⇒ Object (readonly)
Returns the value of attribute protocols.
64 65 66 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 64 def protocols @protocols end |
#scheme ⇒ Object (readonly)
Returns the value of attribute scheme.
61 62 63 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 61 def scheme @scheme end |
#The grouped concrete addresses.(groupedconcreteaddresses.) ⇒ Object (readonly)
67 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 67 attr :addresses |
#The supported upstream HTTP protocol names.(supportedupstreamHTTPprotocolnames.) ⇒ Object (readonly)
64 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 64 attr :protocols |
#The upstream cluster name.(upstreamclustername.) ⇒ Object (readonly)
58 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 58 attr :name |
Class Method Details
.build(name:, scheme:, protocols:, addresses:) ⇒ Object
Build an immutable endpoint.
18 19 20 21 22 23 24 25 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 18 def self.build(name:, scheme:, protocols:, addresses:) new( name.to_s, scheme.to_sym, protocols.map(&:to_s).uniq, addresses, ).tap(&:freeze) end |
.wrap(value) ⇒ Object
Wrap serialized endpoint state.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 30 def self.wrap(value) case value when self value when Hash build(**value) else raise ArgumentError, "Invalid Envoy endpoint: #{value.inspect}" end end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Compare this endpoint with another endpoint by value.
87 88 89 90 91 92 93 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 87 def eql?(other) other.instance_of?(self.class) && @name == other.name && @scheme == other.scheme && @protocols == other.protocols && @addresses == other.addresses end |
#freeze ⇒ Object
Freeze this endpoint and cache its value hash.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 70 def freeze return self if frozen? @name.freeze @protocols.each(&:freeze).freeze @addresses.each do |address| address.each_value(&:freeze) address.freeze end.freeze @hash = self.hash super end |
#hash ⇒ Object
Compute the value hash used when grouping endpoints.
99 100 101 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 99 def hash @hash || [self.class, @name, @scheme, @protocols, @addresses].hash end |
#The upstream application scheme.=(upstreamapplicationscheme. = (value)) ⇒ Object
61 |
# File 'lib/async/service/supervisor/envoy/endpoint.rb', line 61 attr :scheme |