mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 18:13:42 +08:00 
			
		
		
		
	vendor: update buildkit to opentelemetry support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
		
							
								
								
									
										98
									
								
								vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										98
									
								
								vendor/google.golang.org/grpc/internal/serviceconfig/serviceconfig.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -22,14 +22,21 @@ package serviceconfig
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"google.golang.org/grpc/balancer"
 | 
			
		||||
	"google.golang.org/grpc/codes"
 | 
			
		||||
	"google.golang.org/grpc/grpclog"
 | 
			
		||||
	externalserviceconfig "google.golang.org/grpc/serviceconfig"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// BalancerConfig is the balancer config part that service config's
 | 
			
		||||
// loadBalancingConfig fields can be unmarshalled to. It's a json unmarshaller.
 | 
			
		||||
var logger = grpclog.Component("core")
 | 
			
		||||
 | 
			
		||||
// BalancerConfig wraps the name and config associated with one load balancing
 | 
			
		||||
// policy. It corresponds to a single entry of the loadBalancingConfig field
 | 
			
		||||
// from ServiceConfig.
 | 
			
		||||
//
 | 
			
		||||
// It implements the json.Unmarshaler interface.
 | 
			
		||||
//
 | 
			
		||||
// https://github.com/grpc/grpc-proto/blob/54713b1e8bc6ed2d4f25fb4dff527842150b91b2/grpc/service_config/service_config.proto#L247
 | 
			
		||||
type BalancerConfig struct {
 | 
			
		||||
@@ -39,7 +46,31 @@ type BalancerConfig struct {
 | 
			
		||||
 | 
			
		||||
type intermediateBalancerConfig []map[string]json.RawMessage
 | 
			
		||||
 | 
			
		||||
// UnmarshalJSON implements json unmarshaller.
 | 
			
		||||
// MarshalJSON implements the json.Marshaler interface.
 | 
			
		||||
//
 | 
			
		||||
// It marshals the balancer and config into a length-1 slice
 | 
			
		||||
// ([]map[string]config).
 | 
			
		||||
func (bc *BalancerConfig) MarshalJSON() ([]byte, error) {
 | 
			
		||||
	if bc.Config == nil {
 | 
			
		||||
		// If config is nil, return empty config `{}`.
 | 
			
		||||
		return []byte(fmt.Sprintf(`[{%q: %v}]`, bc.Name, "{}")), nil
 | 
			
		||||
	}
 | 
			
		||||
	c, err := json.Marshal(bc.Config)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return []byte(fmt.Sprintf(`[{%q: %s}]`, bc.Name, c)), nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// UnmarshalJSON implements the json.Unmarshaler interface.
 | 
			
		||||
//
 | 
			
		||||
// ServiceConfig contains a list of loadBalancingConfigs, each with a name and
 | 
			
		||||
// config. This method iterates through that list in order, and stops at the
 | 
			
		||||
// first policy that is supported.
 | 
			
		||||
// - If the config for the first supported policy is invalid, the whole service
 | 
			
		||||
//   config is invalid.
 | 
			
		||||
// - If the list doesn't contain any supported policy, the whole service config
 | 
			
		||||
//   is invalid.
 | 
			
		||||
func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
 | 
			
		||||
	var ir intermediateBalancerConfig
 | 
			
		||||
	err := json.Unmarshal(b, &ir)
 | 
			
		||||
@@ -51,13 +82,16 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
 | 
			
		||||
		if len(lbcfg) != 1 {
 | 
			
		||||
			return fmt.Errorf("invalid loadBalancingConfig: entry %v does not contain exactly 1 policy/config pair: %q", i, lbcfg)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		var (
 | 
			
		||||
			name    string
 | 
			
		||||
			jsonCfg json.RawMessage
 | 
			
		||||
		)
 | 
			
		||||
		// Get the key:value pair from the map.
 | 
			
		||||
		// Get the key:value pair from the map. We have already made sure that
 | 
			
		||||
		// the map contains a single entry.
 | 
			
		||||
		for name, jsonCfg = range lbcfg {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		builder := balancer.Get(name)
 | 
			
		||||
		if builder == nil {
 | 
			
		||||
			// If the balancer is not registered, move on to the next config.
 | 
			
		||||
@@ -69,7 +103,7 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
 | 
			
		||||
		parser, ok := builder.(balancer.ConfigParser)
 | 
			
		||||
		if !ok {
 | 
			
		||||
			if string(jsonCfg) != "{}" {
 | 
			
		||||
				grpclog.Warningf("non-empty balancer configuration %q, but balancer does not implement ParseConfig", string(jsonCfg))
 | 
			
		||||
				logger.Warningf("non-empty balancer configuration %q, but balancer does not implement ParseConfig", string(jsonCfg))
 | 
			
		||||
			}
 | 
			
		||||
			// Stop at this, though the builder doesn't support parsing config.
 | 
			
		||||
			return nil
 | 
			
		||||
@@ -88,3 +122,57 @@ func (bc *BalancerConfig) UnmarshalJSON(b []byte) error {
 | 
			
		||||
	// case.
 | 
			
		||||
	return fmt.Errorf("invalid loadBalancingConfig: no supported policies found")
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// MethodConfig defines the configuration recommended by the service providers for a
 | 
			
		||||
// particular method.
 | 
			
		||||
type MethodConfig struct {
 | 
			
		||||
	// WaitForReady indicates whether RPCs sent to this method should wait until
 | 
			
		||||
	// the connection is ready by default (!failfast). The value specified via the
 | 
			
		||||
	// gRPC client API will override the value set here.
 | 
			
		||||
	WaitForReady *bool
 | 
			
		||||
	// Timeout is the default timeout for RPCs sent to this method. The actual
 | 
			
		||||
	// deadline used will be the minimum of the value specified here and the value
 | 
			
		||||
	// set by the application via the gRPC client API.  If either one is not set,
 | 
			
		||||
	// then the other will be used.  If neither is set, then the RPC has no deadline.
 | 
			
		||||
	Timeout *time.Duration
 | 
			
		||||
	// MaxReqSize is the maximum allowed payload size for an individual request in a
 | 
			
		||||
	// stream (client->server) in bytes. The size which is measured is the serialized
 | 
			
		||||
	// payload after per-message compression (but before stream compression) in bytes.
 | 
			
		||||
	// The actual value used is the minimum of the value specified here and the value set
 | 
			
		||||
	// by the application via the gRPC client API. If either one is not set, then the other
 | 
			
		||||
	// will be used.  If neither is set, then the built-in default is used.
 | 
			
		||||
	MaxReqSize *int
 | 
			
		||||
	// MaxRespSize is the maximum allowed payload size for an individual response in a
 | 
			
		||||
	// stream (server->client) in bytes.
 | 
			
		||||
	MaxRespSize *int
 | 
			
		||||
	// RetryPolicy configures retry options for the method.
 | 
			
		||||
	RetryPolicy *RetryPolicy
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RetryPolicy defines the go-native version of the retry policy defined by the
 | 
			
		||||
// service config here:
 | 
			
		||||
// https://github.com/grpc/proposal/blob/master/A6-client-retries.md#integration-with-service-config
 | 
			
		||||
type RetryPolicy struct {
 | 
			
		||||
	// MaxAttempts is the maximum number of attempts, including the original RPC.
 | 
			
		||||
	//
 | 
			
		||||
	// This field is required and must be two or greater.
 | 
			
		||||
	MaxAttempts int
 | 
			
		||||
 | 
			
		||||
	// Exponential backoff parameters. The initial retry attempt will occur at
 | 
			
		||||
	// random(0, initialBackoff). In general, the nth attempt will occur at
 | 
			
		||||
	// random(0,
 | 
			
		||||
	//   min(initialBackoff*backoffMultiplier**(n-1), maxBackoff)).
 | 
			
		||||
	//
 | 
			
		||||
	// These fields are required and must be greater than zero.
 | 
			
		||||
	InitialBackoff    time.Duration
 | 
			
		||||
	MaxBackoff        time.Duration
 | 
			
		||||
	BackoffMultiplier float64
 | 
			
		||||
 | 
			
		||||
	// The set of status codes which may be retried.
 | 
			
		||||
	//
 | 
			
		||||
	// Status codes are specified as strings, e.g., "UNAVAILABLE".
 | 
			
		||||
	//
 | 
			
		||||
	// This field is required and must be non-empty.
 | 
			
		||||
	// Note: a set is used to store this for easy lookup.
 | 
			
		||||
	RetryableStatusCodes map[codes.Code]bool
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user