package config

import "github.com/ydb-platform/ydb-go-sdk/v3/config"

Index

Variables

var (
	// DefaultKeepaliveInterval contains default duration between grpc keepalive
	DefaultKeepaliveInterval    = 10 * time.Second
	MinKeepaliveInterval        = 10 * time.Second
	DefaultDialTimeout          = 5 * time.Second
	DefaultGRPCMsgSize          = 64 * 1024 * 1024 // 64MB
	DefaultGrpcConnectionPolicy = keepalive.ClientParameters{
		Time:                DefaultKeepaliveInterval,
		Timeout:             MinKeepaliveInterval,
		PermitWithoutStream: true,
	}
)

Types

type Config

type Config struct {
	config.Common
	// contains filtered or unexported fields
}

Config contains driver configuration.

func New

func New(opts ...Option) *Config

func (*Config) Balancer

func (c *Config) Balancer() *balancerConfig.Config

Balancer is an optional configuration related to selected balancer. That is, some balancing methods allow to be configured.

func (*Config) ConnectionTTL

func (c *Config) ConnectionTTL() time.Duration

ConnectionTTL defines interval for parking grpc connections.

If ConnectionTTL is zero - connections are not park.

func (*Config) Credentials

func (c *Config) Credentials() credentials.Credentials

func (*Config) Database

func (c *Config) Database() string

Database is a required database name.

func (*Config) DialTimeout

func (c *Config) DialTimeout() time.Duration

DialTimeout is the maximum amount of time a dial will wait for a connect to complete.

If DialTimeout is zero then no timeout is used.

func (*Config) Endpoint

func (c *Config) Endpoint() string

Endpoint is a required starting endpoint for connect

func (*Config) ExcludeGRPCCodesForPessimization

func (c *Config) ExcludeGRPCCodesForPessimization() []grpcCodes.Code

ExcludeGRPCCodesForPessimization defines grpc codes for exclude its from pessimization trigger

func (*Config) GrpcDialOptions

func (c *Config) GrpcDialOptions() []grpc.DialOption

GrpcDialOptions reports about used grpc dialing options

func (*Config) Meta

func (c *Config) Meta() *meta.Meta

Meta reports meta information about database connection

func (*Config) Secure

func (c *Config) Secure() bool

Secure is a flag for secure connection

func (*Config) TLSConfig

func (c *Config) TLSConfig() *tls.Config

TLSConfig reports about TLS configuration

func (*Config) Trace

func (c *Config) Trace() *trace.Driver

Trace contains driver tracing options.

func (*Config) With

func (c *Config) With(opts ...Option) *Config

With makes copy of current Config with specified options

type Option

type Option func(c *Config)

func ExcludeGRPCCodesForPessimization

func ExcludeGRPCCodesForPessimization(codes ...grpcCodes.Code) Option

func WithApplicationName

func WithApplicationName(applicationName string) Option

WithApplicationName add provided application name to all api requests

func WithBalancer

func WithBalancer(balancer *balancerConfig.Config) Option

func WithCertificate

func WithCertificate(certificate *x509.Certificate) Option

WithCertificate appends certificate to TLS config root certificates

func WithConnectionTTL

func WithConnectionTTL(ttl time.Duration) Option

func WithCredentials

func WithCredentials(credentials credentials.Credentials) Option

func WithDatabase

func WithDatabase(database string) Option

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) Option

func WithEndpoint

func WithEndpoint(endpoint string) Option

func WithGrpcOptions

func WithGrpcOptions(option ...grpc.DialOption) Option

WithGrpcOptions appends custom grpc dial options to defaults

func WithInternalDNSResolver

func WithInternalDNSResolver() Option

WithInternalDNSResolver

Deprecated: always used internal dns-resolver. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated

func WithMinTLSVersion

func WithMinTLSVersion(minVersion uint16) Option

WithMinTLSVersion applies minimum TLS version that is acceptable.

func WithNoAutoRetry

func WithNoAutoRetry() Option

WithNoAutoRetry disable auto-retry calls from YDB sub-clients

func WithOperationCancelAfter

func WithOperationCancelAfter(operationCancelAfter time.Duration) Option

WithOperationCancelAfter sets the maximum amount of time a YDB server will process an operation. After timeout exceeds YDB will try to cancel operation and if it succeeds appropriate error will be returned to the client; otherwise processing will be continued.

If OperationCancelAfter is zero then no timeout is used.

func WithOperationTimeout

func WithOperationTimeout(operationTimeout time.Duration) Option

WithOperationTimeout defines the maximum amount of time a YDB server will process an operation. After timeout exceeds YDB will try to cancel operation and regardless of the cancellation appropriate error will be returned to the client.

If OperationTimeout is zero then no timeout is used.

func WithPanicCallback

func WithPanicCallback(panicCallback func(e interface{})) Option

WithPanicCallback applies panic callback to config

func WithRequestsType

func WithRequestsType(requestsType string) Option

func WithRetryBudget

func WithRetryBudget(b budget.Budget) Option

Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental

func WithSecure

func WithSecure(secure bool) Option

WithSecure changes secure connection flag.

Warning: if secure is false - TLS config options has no effect.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig replaces older TLS config

Warning: all early changes of TLS config will be lost

func WithTLSSInsecureSkipVerify

func WithTLSSInsecureSkipVerify() Option

WithTLSSInsecureSkipVerify applies InsecureSkipVerify flag to TLS config

func WithTrace

func WithTrace(t trace.Driver, opts ...trace.DriverComposeOption) Option

func WithTraceRetry

func WithTraceRetry(t *trace.Retry, opts ...trace.RetryComposeOption) Option

func WithUserAgent

func WithUserAgent(userAgent string) Option

WithUserAgent add provided user agent to all api requests

Deprecated: use WithApplicationName instead. Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated

Source Files

config.go defaults.go

Version
v3.75.1
Published
Jul 17, 2024
Platform
linux/amd64
Imports
17 packages
Last checked
26 minutes ago

Tools for package owners.