package balancers

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

Index

Functions

func CreateFromConfig

func CreateFromConfig(s string) (*balancerConfig.Config, error)

func Default

func Default() *balancerConfig.Config

Default balancer used by default

func FromConfig

func FromConfig(config string, opts ...fromConfigOption) *balancerConfig.Config

func Prefer

func Prefer(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool) *balancerConfig.Config

Prefer creates balancer which use endpoints by filter Balancer "balancer" defines balancing algorithm between endpoints selected with filter

func PreferLocalDC

func PreferLocalDC(balancer *balancerConfig.Config) *balancerConfig.Config

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

func PreferLocalDCWithFallBack

func PreferLocalDCWithFallBack(balancer *balancerConfig.Config) *balancerConfig.Config

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

func PreferLocations

func PreferLocations(balancer *balancerConfig.Config, locations ...string) *balancerConfig.Config

PreferLocations creates balancer which use endpoints only in selected locations (such as "ABC", "DEF", etc.) Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location

func PreferLocationsWithFallback

func PreferLocationsWithFallback(balancer *balancerConfig.Config, locations ...string) *balancerConfig.Config

PreferLocationsWithFallback creates balancer which use endpoints only in selected locations Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead

func PreferNearestDC

func PreferNearestDC(balancer *balancerConfig.Config) *balancerConfig.Config

PreferNearestDC creates balancer which use endpoints only in location such as initial endpoint location Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location PreferNearestDC balancer try to autodetect local DC from client side.

func PreferNearestDCWithFallBack

func PreferNearestDCWithFallBack(balancer *balancerConfig.Config) *balancerConfig.Config

PreferNearestDCWithFallBack creates balancer which use endpoints only in location such as initial endpoint location Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead

func PreferWithFallback

func PreferWithFallback(balancer *balancerConfig.Config, filter func(endpoint Endpoint) bool) *balancerConfig.Config

PreferWithFallback creates balancer which use endpoints by filter Balancer "balancer" defines balancing algorithm between endpoints selected with filter If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead

func RandomChoice

func RandomChoice() *balancerConfig.Config

func RoundRobin

func RoundRobin() *balancerConfig.Config

Deprecated: RoundRobin is an alias to RandomChoice now Will be removed after Oct 2024. Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated

func SingleConn

func SingleConn() *balancerConfig.Config

func WithNodeID

func WithNodeID(ctx context.Context, nodeID uint32) context.Context

WithNodeID returns the copy of context with NodeID which the client balancer will prefer on step of choose YDB endpoint step

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

func WithParseErrorFallbackBalancer

func WithParseErrorFallbackBalancer(b *balancerConfig.Config) fromConfigOption

func WithParseErrorHandler

func WithParseErrorHandler(errorHandler func(error)) fromConfigOption

Types

type Endpoint

type Endpoint interface {
	NodeID() uint32
	Address() string
	Location() string

	// Deprecated: LocalDC check "local" by compare endpoint location with discovery "selflocation" field.
	// It work good only if connection url always point to local dc.
	// Will be removed after Oct 2024.
	// Read about versioning policy: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
	LocalDC() bool
}

Source Files

balancers.go config.go context.go

Version
v3.80.10
Published
Sep 19, 2024
Platform
windows/amd64
Imports
10 packages
Last checked
11 minutes ago

Tools for package owners.