Class: Async::GRPC::XDS::Resources::Cluster

Inherits:
Object
  • Object
show all
Defined in:
lib/async/grpc/xds/resources.rb

Overview

Represents a discovered cluster Based on envoy.config.cluster.v3.Cluster

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Cluster

Initialize cluster from protobuf or hash



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/async/grpc/xds/resources.rb', line 18

def initialize(data)
	if data.is_a?(Hash)
		@name = data[:name]
		@type = parse_type(data[:type])
		@load_balancer_policy = parse_load_balancer_policy(data[:load_balancer_policy] || data[:lb_policy])
		@health_checks = parse_health_checks(data[:health_checks] || [])
		@circuit_breakers = data[:circuit_breakers]
		@eds_cluster_config = data[:eds_cluster_config]
	else
		# Assume protobuf object
		@name = data.name
		@type = parse_type(data.type)
		@load_balancer_policy = parse_load_balancer_policy(data.lb_policy)
		@health_checks = parse_health_checks(data.health_checks || [])
		@circuit_breakers = data.circuit_breakers
		@eds_cluster_config = data.eds_cluster_config
	end
end

Instance Attribute Details

#circuit_breakersObject (readonly)

Returns the value of attribute circuit_breakers.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def circuit_breakers
  @circuit_breakers
end

#eds_cluster_configObject (readonly)

Returns the value of attribute eds_cluster_config.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def eds_cluster_config
  @eds_cluster_config
end

#health_checksObject (readonly)

Returns the value of attribute health_checks.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def health_checks
  @health_checks
end

#load_balancer_policyObject (readonly)

Returns the value of attribute load_balancer_policy.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def load_balancer_policy
  @load_balancer_policy
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/async/grpc/xds/resources.rb', line 14

def type
  @type
end

Class Method Details

.from_proto(proto) ⇒ Object

Create Cluster from protobuf message



40
41
42
# File 'lib/async/grpc/xds/resources.rb', line 40

def self.from_proto(proto)
	new(proto)
end

Instance Method Details

#eds_cluster?Boolean

Determine whether this cluster uses the Endpoint Discovery Service.

Returns:

  • (Boolean)


46
47
48
# File 'lib/async/grpc/xds/resources.rb', line 46

def eds_cluster?
	@type == :EDS
end