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



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

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.



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

def circuit_breakers
  @circuit_breakers
end

#eds_cluster_configObject (readonly)

Returns the value of attribute eds_cluster_config.



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

def eds_cluster_config
  @eds_cluster_config
end

#health_checksObject (readonly)

Returns the value of attribute health_checks.



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

def health_checks
  @health_checks
end

#load_balancer_policyObject (readonly)

Returns the value of attribute load_balancer_policy.



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

def load_balancer_policy
  @load_balancer_policy
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.from_proto(proto) ⇒ Object

Create Cluster from protobuf message



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

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

Instance Method Details

#eds_cluster?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/async/grpc/xds/resources.rb', line 43

def eds_cluster?
	@type == :EDS
end