/*
 *
 * Copyright 2017 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

// Package roundrobin defines a roundrobin balancer. Roundrobin balancer is // installed as one of the default balancers in gRPC, users don't need to // explicitly install this balancer.
package roundrobin import ( internalgrpclog ) // Name is the name of round_robin balancer. const Name = "round_robin" var logger = grpclog.Component("roundrobin") func () { balancer.Register(builder{}) } type builder struct{} func ( builder) () string { return Name } func ( builder) ( balancer.ClientConn, balancer.BuildOptions) balancer.Balancer { := balancer.Get(pickfirstleaf.Name).Build := &rrBalancer{ cc: , Balancer: endpointsharding.NewBalancer(, , , endpointsharding.Options{}), } .logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[%p] ", )) .logger.Infof("Created") return } type rrBalancer struct { balancer.Balancer cc balancer.ClientConn logger *internalgrpclog.PrefixLogger } func ( *rrBalancer) ( balancer.ClientConnState) error { return .Balancer.UpdateClientConnState(balancer.ClientConnState{ // Enable the health listener in pickfirst children for client side health // checks and outlier detection, if configured. ResolverState: pickfirstleaf.EnableHealthListener(.ResolverState), }) }