Skip to content

Commit

Permalink
restore LocalDC interface func
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Apr 8, 2024
1 parent ac576fa commit 2f35f37
Show file tree
Hide file tree
Showing 15 changed files with 272 additions and 266 deletions.
3 changes: 3 additions & 0 deletions balancers/balancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ type Endpoint interface {
NodeID() uint32
Address() string
Location() string

// Deprecated: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
LocalDC() bool
}

type filterFunc func(info balancerConfig.Info, c conn.Conn) bool
Expand Down
14 changes: 9 additions & 5 deletions internal/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
type Info interface {
NodeID() uint32
Address() string
LocalDC() bool
Location() string
LastUpdated() time.Time
LoadFactor() float32

// Deprecated: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
LocalDC() bool
}

type Endpoint interface {
Expand All @@ -23,17 +25,18 @@ type Endpoint interface {
Touch(opts ...Option)
}

type endpoint struct {
type endpoint struct { //nolint:maligned
mu sync.RWMutex
id uint32
address string
location string
services []string

loadFactor float32
local bool

loadFactor float32
lastUpdated time.Time

// Deprecated: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
local bool
}

func (e *endpoint) Copy() Endpoint {
Expand Down Expand Up @@ -86,6 +89,7 @@ func (e *endpoint) Location() string {
return e.location
}

// Deprecated: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func (e *endpoint) LocalDC() bool {
e.mu.RLock()
defer e.mu.RUnlock()
Expand Down
1 change: 1 addition & 0 deletions internal/mock/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func (e *Endpoint) Address() string {
return e.AddrField
}

// Deprecated: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#deprecated
func (e *Endpoint) LocalDC() bool {
return e.LocalDCField
}
Expand Down
14 changes: 5 additions & 9 deletions metrics/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
// driver makes driver with New publishing
func driver(config Config) (t trace.Driver) {
config = config.WithSystem("driver")
endpoints := config.WithSystem("balancer").GaugeVec("endpoints", "local_dc", "az")
endpoints := config.WithSystem("balancer").GaugeVec("endpoints", "az")
balancersDiscoveries := config.WithSystem("balancer").CounterVec("discoveries", "status", "cause")
balancerUpdates := config.WithSystem("balancer").CounterVec("updates", "cause")
conns := config.GaugeVec("conns", "endpoint", "node_id")
Expand All @@ -20,8 +20,7 @@ func driver(config Config) (t trace.Driver) {
tli := config.CounterVec("transaction_locks_invalidated")

type endpointKey struct {
localDC bool
az string
az string
}
knownEndpoints := make(map[endpointKey]struct{})

Expand Down Expand Up @@ -100,25 +99,22 @@ func driver(config Config) (t trace.Driver) {
newEndpoints := make(map[endpointKey]int, len(info.Endpoints))
for _, e := range info.Endpoints {
e := endpointKey{
localDC: e.LocalDC(),
az: e.Location(),
az: e.Location(),
}
newEndpoints[e]++
}
for e := range knownEndpoints {
if _, has := newEndpoints[e]; !has {
delete(knownEndpoints, e)
endpoints.With(map[string]string{
"local_dc": strconv.FormatBool(e.localDC),
"az": e.az,
"az": e.az,
}).Set(0)
}
}
for e, count := range newEndpoints {
knownEndpoints[e] = struct{}{}
endpoints.With(map[string]string{
"local_dc": strconv.FormatBool(e.localDC),
"az": e.az,
"az": e.az,
}).Set(float64(count))
}
}
Expand Down
106 changes: 53 additions & 53 deletions trace/coordination.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,53 +15,53 @@ type (
// Coordination specified trace of coordination client activity.
// gtrace:gen
Coordination struct {
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnNew func(CoordinationNewStartInfo) func(CoordinationNewDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnCreateNode func(CoordinationCreateNodeStartInfo) func(CoordinationCreateNodeDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnAlterNode func(CoordinationAlterNodeStartInfo) func(CoordinationAlterNodeDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnDropNode func(CoordinationDropNodeStartInfo) func(CoordinationDropNodeDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnDescribeNode func(CoordinationDescribeNodeStartInfo) func(CoordinationDescribeNodeDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSession func(CoordinationSessionStartInfo) func(CoordinationSessionDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnClose func(CoordinationCloseStartInfo) func(CoordinationCloseDoneInfo)

// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnStreamNew func(CoordinationStreamNewStartInfo) func(CoordinationStreamNewDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStarted func(CoordinationSessionStartedInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStartTimeout func(CoordinationSessionStartTimeoutInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionKeepAliveTimeout func(CoordinationSessionKeepAliveTimeoutInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStopped func(CoordinationSessionStoppedInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStopTimeout func(CoordinationSessionStopTimeoutInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionClientTimeout func(CoordinationSessionClientTimeoutInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionServerExpire func(CoordinationSessionServerExpireInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionServerError func(CoordinationSessionServerErrorInfo)

// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionReceive func(CoordinationSessionReceiveStartInfo) func(CoordinationSessionReceiveDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionReceiveUnexpected func(CoordinationSessionReceiveUnexpectedInfo)

// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStop func(CoordinationSessionStopInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionStart func(CoordinationSessionStartStartInfo) func(CoordinationSessionStartDoneInfo)
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
OnSessionSend func(CoordinationSessionSendStartInfo) func(CoordinationSessionSendDoneInfo)
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationNewStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -70,9 +70,9 @@ type (
Context *context.Context
Call call
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationNewDoneInfo struct{}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationCloseStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -81,11 +81,11 @@ type (
Context *context.Context
Call call
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationCloseDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationCreateNodeStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -96,11 +96,11 @@ type (

Path string
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationCreateNodeDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationAlterNodeStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -111,11 +111,11 @@ type (

Path string
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationAlterNodeDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationDropNodeStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -126,11 +126,11 @@ type (

Path string
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationDropNodeDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationDescribeNodeStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -141,11 +141,11 @@ type (

Path string
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationDescribeNodeDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStartInfo struct {
// Context make available context in trace callback function.
// Pointer to context provide replacement of context in trace callback function.
Expand All @@ -156,78 +156,78 @@ type (

Path string
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationStreamNewStartInfo struct{}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationStreamNewDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStartedInfo struct {
SessionID uint64
ExpectedSessionID uint64
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStartTimeoutInfo struct {
Timeout time.Duration
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionKeepAliveTimeoutInfo struct {
LastGoodResponseTime time.Time
Timeout time.Duration
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStoppedInfo struct {
SessionID uint64
ExpectedSessionID uint64
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStopTimeoutInfo struct {
Timeout time.Duration
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionClientTimeoutInfo struct {
LastGoodResponseTime time.Time
Timeout time.Duration
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionServerExpireInfo struct {
Failure *Ydb_Coordination.SessionResponse_Failure
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionServerErrorInfo struct {
Failure *Ydb_Coordination.SessionResponse_Failure
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionReceiveStartInfo struct{}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionReceiveDoneInfo struct {
Response *Ydb_Coordination.SessionResponse
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionReceiveUnexpectedInfo struct {
Response *Ydb_Coordination.SessionResponse
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStartStartInfo struct{}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStartDoneInfo struct {
Error error
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionStopInfo struct {
SessionID uint64
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionSendStartInfo struct {
Request *Ydb_Coordination.SessionRequest
}
// Unstable: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#unstable
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
CoordinationSessionSendDoneInfo struct {
Error error
}
Expand Down
Loading

0 comments on commit 2f35f37

Please sign in to comment.