Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrowConfig added in v1.1.0

type ArrowConfig struct {
	UseArrowBatches         bool
	UseArrowNativeDecimal   bool
	UseArrowNativeTimestamp bool

	// the following are currently not supported
	UseArrowNativeComplexTypes  bool
	UseArrowNativeIntervalTypes bool
}

func (ArrowConfig) DeepCopy added in v1.1.0

func (arrowConfig ArrowConfig) DeepCopy() ArrowConfig

DeepCopy returns a true deep copy of UserConfig

func (ArrowConfig) WithDefaults added in v1.1.0

func (ucfg ArrowConfig) WithDefaults() ArrowConfig

type CloudFetchConfig added in v1.4.0

type CloudFetchConfig struct {
	UseCloudFetch                bool
	MaxDownloadThreads           int
	MaxFilesInMemory             int
	MinTimeToExpiry              time.Duration
	CloudFetchSpeedThresholdMbps float64 // Minimum download speed in MBps before WARN logging (default: 0.1)
	HTTPClient                   *http.Client
}

func (CloudFetchConfig) DeepCopy added in v1.4.0

func (cfg CloudFetchConfig) DeepCopy() CloudFetchConfig

func (CloudFetchConfig) WithDefaults added in v1.4.0

func (cfg CloudFetchConfig) WithDefaults() CloudFetchConfig

type Config

type Config struct {
	UserConfig
	TLSConfig *tls.Config // nil disables TLS
	ArrowConfig
	PollInterval              time.Duration
	ClientTimeout             time.Duration // max time the http request can last
	PingTimeout               time.Duration // max time allowed for ping
	CanUseMultipleCatalogs    bool
	DriverName                string
	DriverVersion             string
	ThriftProtocol            string
	ThriftTransport           string
	ThriftProtocolVersion     cli_service.TProtocolVersion
	ThriftDebugClientProtocol bool
}

Driver Configurations. Only UserConfig are currently exposed to users

func WithDefaults

func WithDefaults() *Config

WithDefaults provides default settings for Config

func (*Config) DeepCopy

func (c *Config) DeepCopy() *Config

DeepCopy returns a true deep copy of Config

func (*Config) ToEndpointURL

func (c *Config) ToEndpointURL() (string, error)

ToEndpointURL generates the endpoint URL from Config that a Thrift client will connect to

type ConfigValue added in v1.10.0

type ConfigValue[T any] struct {
	// contains filtered or unexported fields
}

ConfigValue represents a configuration value that can be set by client or resolved from server. This implements the config overlay pattern: client > server > default

T is the type of the configuration value (bool, string, int, etc.)

Example usage:

type MyConfig struct {
    EnableFeature ConfigValue[bool]
    BatchSize     ConfigValue[int]
}

// Client explicitly sets value (overrides server)
config.EnableFeature = NewConfigValue(true)

// Client doesn't set value (use server)
config.EnableFeature = ConfigValue[bool]{} // nil/unset

// Resolve value with overlay priority
enabled := config.EnableFeature.Resolve(ctx, serverResolver, defaultValue)

func NewConfigValue added in v1.10.0

func NewConfigValue[T any](value T) ConfigValue[T]

NewConfigValue creates a ConfigValue with a client-set value. The value will override any server-side configuration.

func ParseBoolConfigValue added in v1.10.0

func ParseBoolConfigValue(params map[string]string, key string) ConfigValue[bool]

ParseBoolConfigValue parses a string value into a ConfigValue[bool]. Returns unset ConfigValue if the parameter is not present.

Example:

params := map[string]string{"enableFeature": "true"}
value := ParseBoolConfigValue(params, "enableFeature")
// value.IsSet() == true, value.Get() == (true, true)

func ParseIntConfigValue added in v1.10.0

func ParseIntConfigValue(params map[string]string, key string) ConfigValue[int]

ParseIntConfigValue parses a string value into a ConfigValue[int]. Returns unset ConfigValue if the parameter is not present or invalid.

func ParseStringConfigValue added in v1.10.0

func ParseStringConfigValue(params map[string]string, key string) ConfigValue[string]

ParseStringConfigValue parses a string value into a ConfigValue[string]. Returns unset ConfigValue if the parameter is not present.

func (ConfigValue[T]) Get added in v1.10.0

func (cv ConfigValue[T]) Get() (T, bool)

Get returns the client-set value and whether it was set. If not set, returns zero value and false.

func (ConfigValue[T]) IsSet added in v1.10.0

func (cv ConfigValue[T]) IsSet() bool

IsSet returns true if the client explicitly set this configuration value.

func (ConfigValue[T]) Resolve added in v1.10.0

func (cv ConfigValue[T]) Resolve(
	ctx context.Context,
	serverResolver ServerResolver[T],
	defaultValue T,
) T

Resolve applies config overlay priority to determine the final value:

Priority 1: Client Config - if explicitly set (overrides server)
Priority 2: Server Config - resolved via serverResolver (when client doesn't set)
Priority 3: Default Value - used when server unavailable/errors (fail-safe)

Parameters:

  • ctx: Context for server requests
  • serverResolver: How to fetch from server (can be nil if no server config)
  • defaultValue: Fail-safe default when client unset and server unavailable

Returns: The resolved configuration value following overlay priority

func (ConfigValue[T]) ResolveWithContext added in v1.10.0

func (cv ConfigValue[T]) ResolveWithContext(
	ctx context.Context,
	host string,
	httpClient *http.Client,
	serverResolver ServerResolver[T],
	defaultValue T,
) T

ResolveWithContext is a more flexible version that takes host and httpClient. This is the recommended method for production use.

type ServerResolver added in v1.10.0

type ServerResolver[T any] interface {
	// Resolve fetches the configuration value from the server.
	// Returns the value and any error encountered.
	// On error, the config overlay will fall back to the default value.
	Resolve(ctx context.Context, host string, httpClient *http.Client) (T, error)
}

ServerResolver defines how to fetch a configuration value from the server. Implementations should handle caching, retries, and error handling.

type UserConfig

type UserConfig struct {
	Protocol       string
	Host           string // from databricks UI
	Port           int    // from databricks UI
	HTTPPath       string // from databricks UI
	Catalog        string
	Schema         string
	Authenticator  auth.Authenticator
	AccessToken    string        // from databricks UI
	MaxRows        int           // max rows per page
	QueryTimeout   time.Duration // Timeout passed to server for query processing
	UserAgentEntry string
	Location       *time.Location
	SessionParams  map[string]string
	RetryWaitMin   time.Duration
	RetryWaitMax   time.Duration
	RetryMax       int
	// Telemetry configuration
	// Uses config overlay pattern: client > server > default.
	// Unset = check server feature flag; explicitly true/false overrides the server.
	EnableTelemetry          ConfigValue[bool]
	TelemetryBatchSize       int           // 0 = use default (100)
	TelemetryFlushInterval   time.Duration // 0 = use default (5s)
	TelemetryRetryCount      int           // -1 = use default (3); 0 = disable retries; set via telemetry_retry_count
	TelemetryRetryDelay      time.Duration // 0 = use default (100ms); set via telemetry_retry_delay
	Transport                http.RoundTripper
	UseLz4Compression        bool
	EnableMetricViewMetadata bool
	CloudFetchConfig
}

UserConfig is the set of configurations exposed to users

func ParseDSN

func ParseDSN(dsn string) (UserConfig, error)

ParseDSN constructs UserConfig and CloudFetchConfig by parsing DSN string supplied to `sql.Open()`

func (UserConfig) DeepCopy

func (ucfg UserConfig) DeepCopy() UserConfig

DeepCopy returns a true deep copy of UserConfig

func (UserConfig) WithDefaults

func (ucfg UserConfig) WithDefaults() UserConfig

WithDefaults provides default settings for optional fields in UserConfig

Jump to

Keyboard shortcuts

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