option

package
v1.43.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package option contains common code for dealing with client options.

Index

Constants

View Source
const (
	// LoadBalancingStrategyEnvVar is the environment variable to control the gRPC load balancing strategy.
	LoadBalancingStrategyEnvVar = "CBT_LOAD_BALANCING_STRATEGY"
	// RoundRobinLBPolicy is the policy name for round-robin.
	RoundRobinLBPolicy = "round_robin"
	// LeastInFlightLBPolicy is the policy name for least in flight (custom).
	LeastInFlightLBPolicy = "least_in_flight"
	// PowerOfTwoLeastInFlightLBPolicy is the policy name for power of two least in flight (custom).
	PowerOfTwoLeastInFlightLBPolicy = "power_of_two_least_in_flight"
	// BigtableConnectionPoolEnvVar is the env var for enabling Bigtable Connection Pool.
	BigtableConnectionPoolEnvVar = "CBT_BIGTABLE_CONN_POOL"
)

Variables

This section is empty.

Functions

func ClientInterceptorOptions added in v1.2.0

func ClientInterceptorOptions(stream []grpc.StreamClientInterceptor, unary []grpc.UnaryClientInterceptor) []option.ClientOption

ClientInterceptorOptions returns client options to use for the client's gRPC connection, using the given streaming and unary RPC interceptors.

The passed interceptors are applied after internal interceptors which inject Google client information into the gRPC context.

func Debugf added in v1.42.0

func Debugf(logger *log.Logger, format string, v ...interface{})

Debugf logs the given message *only if* the global Debug flag is true. It reuses Logf to handle the nil logger logic and prepends "DEBUG: " to the message.

func DefaultClientOptions

func DefaultClientOptions(endpoint, mtlsEndpoint, scope, userAgent string) ([]option.ClientOption, error)

DefaultClientOptions returns the default client options to use for the client's gRPC connection.

func EnableBigtableConnectionPool added in v1.41.0

func EnableBigtableConnectionPool() bool

EnableBigtableConnectionPool uses new conn pool if envVar is set.

Types

type ConnectionRecycleConfig added in v1.43.0

type ConnectionRecycleConfig struct {
	// MaxAge is the base lifespan of a connection.
	MaxAge time.Duration
	// Jitter is the random buffer added to MaxAge which can allow for connection to be recycled.
	MaxJitter time.Duration
	// RunFrequency determines how often the recycler checks for expired connections.
	RunFrequency time.Duration
}

ConnectionRecycleConfig controls the behavior of the connection recycler.

func DefaultConnectionRecycleConfig added in v1.43.0

func DefaultConnectionRecycleConfig() ConnectionRecycleConfig

DefaultConnectionRecycleConfig returns the default configuration: MaxAge: 45 minutes, Jitter: 5 minutes, RunFrequency: 1 minute, Enabled: true.

type DynamicChannelPoolConfig added in v1.42.0

type DynamicChannelPoolConfig struct {
	Enabled                          bool          // Whether dynamic scaling is enabled.
	MinConns                         int           // Minimum conns allowed
	MaxConns                         int           // Maximum conns allowed.
	AvgLoadHighThreshold             float64       // Average weighted load per connection to trigger scale-up.
	AvgLoadLowThreshold              float64       // Average weighted load per connection to trigger scale-down.
	MinScalingInterval               time.Duration // Minimum time between scaling operations (both up and down).
	CheckInterval                    time.Duration // How often to check if scaling is needed.
	MaxRemoveConns                   int           // Maximum number of connections to remove at once.
	ContinuousDownscaleRunsThreshold int           // Continous downscale signals for downscale to actually occur
	MaxScaleUpPercentage             int           // MaxScaleUpPercentage limits the maximum number of connections added during a single

}

DynamicChannelPoolConfig holds the parameters for dynamic channel pool scaling.

func DefaultDynamicChannelPoolConfig added in v1.42.0

func DefaultDynamicChannelPoolConfig() DynamicChannelPoolConfig

DefaultDynamicChannelPoolConfig is default settings for dynamic channel pool

type LoadBalancingStrategy added in v1.41.0

type LoadBalancingStrategy int

LoadBalancingStrategy for connection pool.

const (
	// RoundRobin is the round_robin gRPC load balancing policy.
	RoundRobin LoadBalancingStrategy = iota
	// LeastInFlight is the least_in_flight gRPC load balancing policy (custom).
	LeastInFlight
	// PowerOfTwoLeastInFlight is the power_of_two_least_in_flight gRPC load balancing policy (custom).
	PowerOfTwoLeastInFlight
)

func BigtableLoadBalancingStrategy added in v1.41.0

func BigtableLoadBalancingStrategy() LoadBalancingStrategy

BigtableLoadBalancingStrategy returns the gRPC service config JSON string for the chosen policy.

func (LoadBalancingStrategy) String added in v1.41.0

func (s LoadBalancingStrategy) String() string

String returns the string representation of the LoadBalancingStrategy.

type MetricsReporterConfig added in v1.42.0

type MetricsReporterConfig struct {
	Enabled           bool
	ReportingInterval time.Duration
}

MetricsReporterConfig for periodic reporting MetricsReporterConfig holds the parameters for metrics reporting.

func DefaultMetricsReporterConfig added in v1.42.0

func DefaultMetricsReporterConfig() MetricsReporterConfig

DefaultMetricsReporterConfig with defaults used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL