@@ -3,28 +3,28 @@ package balancers
33import (
44 "strings"
55
6- "github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer"
76 "github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
7+ routerconfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/router/config"
88)
99
1010// Deprecated: RoundRobin is RandomChoice now
11- func RoundRobin () balancer. Balancer {
12- return & balancer .Config {}
11+ func RoundRobin () * routerconfig. Config {
12+ return & routerconfig .Config {}
1313}
1414
15- func RandomChoice () balancer. Balancer {
16- return & balancer .Config {}
15+ func RandomChoice () * routerconfig. Config {
16+ return & routerconfig .Config {}
1717}
1818
19- func SingleConn () balancer. Balancer {
20- return & balancer .Config {
19+ func SingleConn () * routerconfig. Config {
20+ return & routerconfig .Config {
2121 SingleConn : true ,
2222 }
2323}
2424
2525// PreferLocalDC creates balancer which use endpoints only in location such as initial endpoint location
2626// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
27- func PreferLocalDC (balancer balancer. Balancer ) balancer. Balancer {
27+ func PreferLocalDC (balancer * routerconfig. Config ) * routerconfig. Config {
2828 balancer .IsPreferConn = func (c conn.Conn ) bool {
2929 return c .Endpoint ().LocalDC ()
3030 }
@@ -34,15 +34,15 @@ func PreferLocalDC(balancer balancer.Balancer) balancer.Balancer {
3434// PreferLocalDCWithFallBack creates balancer which use endpoints only in location such as initial endpoint location
3535// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
3636// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
37- func PreferLocalDCWithFallBack (balancer balancer. Balancer ) balancer. Balancer {
37+ func PreferLocalDCWithFallBack (balancer * routerconfig. Config ) * routerconfig. Config {
3838 balancer = PreferLocalDC (balancer )
3939 balancer .AllowFalback = true
4040 return balancer
4141}
4242
4343// PreferLocations creates balancer which use endpoints only in selected locations (such as "ABC", "DEF", etc.)
4444// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
45- func PreferLocations (balancer balancer. Balancer , locations ... string ) balancer. Balancer {
45+ func PreferLocations (balancer * routerconfig. Config , locations ... string ) * routerconfig. Config {
4646 if len (locations ) == 0 {
4747 panic ("empty list of locations" )
4848 }
@@ -64,7 +64,7 @@ func PreferLocations(balancer balancer.Balancer, locations ...string) balancer.B
6464// PreferLocationsWithFallback creates balancer which use endpoints only in selected locations
6565// Balancer "balancer" defines balancing algorithm between endpoints selected with filter by location
6666// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
67- func PreferLocationsWithFallback (balancer balancer. Balancer , locations ... string ) balancer. Balancer {
67+ func PreferLocationsWithFallback (balancer * routerconfig. Config , locations ... string ) * routerconfig. Config {
6868 balancer = PreferLocations (balancer , locations ... )
6969 balancer .AllowFalback = true
7070 return balancer
@@ -79,7 +79,7 @@ type Endpoint interface {
7979
8080// Prefer creates balancer which use endpoints by filter
8181// Balancer "balancer" defines balancing algorithm between endpoints selected with filter
82- func Prefer (balancer balancer. Balancer , filter func (endpoint Endpoint ) bool ) balancer. Balancer {
82+ func Prefer (balancer * routerconfig. Config , filter func (endpoint Endpoint ) bool ) * routerconfig. Config {
8383 balancer .IsPreferConn = func (c conn.Conn ) bool {
8484 return filter (c .Endpoint ())
8585 }
@@ -89,13 +89,13 @@ func Prefer(balancer balancer.Balancer, filter func(endpoint Endpoint) bool) bal
8989// PreferWithFallback creates balancer which use endpoints by filter
9090// Balancer "balancer" defines balancing algorithm between endpoints selected with filter
9191// If filter returned zero endpoints from all discovery endpoints list - used all endpoint instead
92- func PreferWithFallback (balancer balancer. Balancer , filter func (endpoint Endpoint ) bool ) balancer. Balancer {
92+ func PreferWithFallback (balancer * routerconfig. Config , filter func (endpoint Endpoint ) bool ) * routerconfig. Config {
9393 balancer = Prefer (balancer , filter )
9494 balancer .AllowFalback = true
9595 return balancer
9696}
9797
9898// Default balancer used by default
99- func Default () balancer. Balancer {
99+ func Default () * routerconfig. Config {
100100 return RandomChoice ()
101101}
0 commit comments