mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 03:42:25 -05:00 
			
		
		
		
	[chore]: Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc (#3888)
This commit is contained in:
		
					parent
					
						
							
								85e17b3e78
							
						
					
				
			
			
				commit
				
					
						252a17a691
					
				
			
		
					 97 changed files with 3821 additions and 1018 deletions
				
			
		
							
								
								
									
										78
									
								
								vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										78
									
								
								vendor/google.golang.org/grpc/balancer/roundrobin/roundrobin.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -22,12 +22,13 @@ | |||
| package roundrobin | ||||
| 
 | ||||
| import ( | ||||
| 	rand "math/rand/v2" | ||||
| 	"sync/atomic" | ||||
| 	"fmt" | ||||
| 
 | ||||
| 	"google.golang.org/grpc/balancer" | ||||
| 	"google.golang.org/grpc/balancer/base" | ||||
| 	"google.golang.org/grpc/balancer/endpointsharding" | ||||
| 	"google.golang.org/grpc/balancer/pickfirst/pickfirstleaf" | ||||
| 	"google.golang.org/grpc/grpclog" | ||||
| 	internalgrpclog "google.golang.org/grpc/internal/grpclog" | ||||
| ) | ||||
| 
 | ||||
| // Name is the name of round_robin balancer. | ||||
|  | @ -35,47 +36,44 @@ const Name = "round_robin" | |||
| 
 | ||||
| var logger = grpclog.Component("roundrobin") | ||||
| 
 | ||||
| // newBuilder creates a new roundrobin balancer builder. | ||||
| func newBuilder() balancer.Builder { | ||||
| 	return base.NewBalancerBuilder(Name, &rrPickerBuilder{}, base.Config{HealthCheck: true}) | ||||
| } | ||||
| 
 | ||||
| func init() { | ||||
| 	balancer.Register(newBuilder()) | ||||
| 	balancer.Register(builder{}) | ||||
| } | ||||
| 
 | ||||
| type rrPickerBuilder struct{} | ||||
| type builder struct{} | ||||
| 
 | ||||
| func (*rrPickerBuilder) Build(info base.PickerBuildInfo) balancer.Picker { | ||||
| 	logger.Infof("roundrobinPicker: Build called with info: %v", info) | ||||
| 	if len(info.ReadySCs) == 0 { | ||||
| 		return base.NewErrPicker(balancer.ErrNoSubConnAvailable) | ||||
| func (bb builder) Name() string { | ||||
| 	return Name | ||||
| } | ||||
| 
 | ||||
| func (bb builder) Build(cc balancer.ClientConn, opts balancer.BuildOptions) balancer.Balancer { | ||||
| 	childBuilder := balancer.Get(pickfirstleaf.Name).Build | ||||
| 	bal := &rrBalancer{ | ||||
| 		cc:       cc, | ||||
| 		Balancer: endpointsharding.NewBalancer(cc, opts, childBuilder, endpointsharding.Options{}), | ||||
| 	} | ||||
| 	scs := make([]balancer.SubConn, 0, len(info.ReadySCs)) | ||||
| 	for sc := range info.ReadySCs { | ||||
| 		scs = append(scs, sc) | ||||
| 	} | ||||
| 	return &rrPicker{ | ||||
| 		subConns: scs, | ||||
| 		// Start at a random index, as the same RR balancer rebuilds a new | ||||
| 		// picker when SubConn states change, and we don't want to apply excess | ||||
| 		// load to the first server in the list. | ||||
| 		next: uint32(rand.IntN(len(scs))), | ||||
| 	bal.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf("[%p] ", bal)) | ||||
| 	bal.logger.Infof("Created") | ||||
| 	return bal | ||||
| } | ||||
| 
 | ||||
| type rrBalancer struct { | ||||
| 	balancer.Balancer | ||||
| 	cc     balancer.ClientConn | ||||
| 	logger *internalgrpclog.PrefixLogger | ||||
| } | ||||
| 
 | ||||
| func (b *rrBalancer) UpdateClientConnState(ccs balancer.ClientConnState) error { | ||||
| 	return b.Balancer.UpdateClientConnState(balancer.ClientConnState{ | ||||
| 		// Enable the health listener in pickfirst children for client side health | ||||
| 		// checks and outlier detection, if configured. | ||||
| 		ResolverState: pickfirstleaf.EnableHealthListener(ccs.ResolverState), | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| func (b *rrBalancer) ExitIdle() { | ||||
| 	// Should always be ok, as child is endpoint sharding. | ||||
| 	if ei, ok := b.Balancer.(balancer.ExitIdler); ok { | ||||
| 		ei.ExitIdle() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| type rrPicker struct { | ||||
| 	// subConns is the snapshot of the roundrobin balancer when this picker was | ||||
| 	// created. The slice is immutable. Each Get() will do a round robin | ||||
| 	// selection from it and return the selected SubConn. | ||||
| 	subConns []balancer.SubConn | ||||
| 	next     uint32 | ||||
| } | ||||
| 
 | ||||
| func (p *rrPicker) Pick(balancer.PickInfo) (balancer.PickResult, error) { | ||||
| 	subConnsLen := uint32(len(p.subConns)) | ||||
| 	nextIndex := atomic.AddUint32(&p.next, 1) | ||||
| 
 | ||||
| 	sc := p.subConns[nextIndex%subConnsLen] | ||||
| 	return balancer.PickResult{SubConn: sc}, nil | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue