Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherednik committed Nov 1, 2024
1 parent 5838b4e commit a04d2be
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 31 deletions.
10 changes: 10 additions & 0 deletions internal/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,16 @@ func newConn(e endpoint.Endpoint, config Config, opts ...option) *conn {
return c
}

func ModifyConn(cc grpc.ClientConnInterface, nodeID uint32) grpc.ClientConnInterface {
if nodeID != 0 {
return conn.WithContextModifier(cc, func(ctx context.Context) context.Context {

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 23.3, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / experiment (1.23.x, nightly, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.1, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.2, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 23.3, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 23.3, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 24.1, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.2, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.1, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 24.2, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, macOS)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, windows)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)

Check failure on line 609 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

conn.WithContextModifier undefined (type conn has no field or method WithContextModifier)
return balancerContext.WithNodeID(ctx, nodeID)

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 23.3, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / experiment (1.23.x, nightly, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.1, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.2, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 23.3, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 23.3, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 24.1, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.2, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.1, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / integration (1.23.x, 24.2, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, macOS)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.23.x, windows)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

undefined: balancerContext

Check failure on line 610 in internal/conn/conn.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

undefined: balancerContext
})
} else {
return cc
}
}

func New(e endpoint.Endpoint, config Config, opts ...option) Conn {
return newConn(e, config, opts...)
}
Expand Down
15 changes: 2 additions & 13 deletions internal/query/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/closer"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
balancerContext "github.com/ydb-platform/ydb-go-sdk/v3/internal/endpoint"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/operation"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/pool"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query/config"
Expand Down Expand Up @@ -41,7 +40,7 @@ type (
closer.Closer

Stats() pool.Stats
With(ctx context.Context, f func(ctx context.Context, s *Session) error, preferredNodeID uint32, opts ...retry.Option) error
With(ctx context.Context, f func(context.Context, *Session) error, nodeID uint32, opts ...retry.Option) error
}
Client struct {
config *config.Config
Expand Down Expand Up @@ -514,16 +513,6 @@ func (c *Client) DoTx(ctx context.Context, op query.TxOperation, opts ...options
return nil
}

func modifyConn(cc grpc.ClientConnInterface, nodeID uint32) grpc.ClientConnInterface {
if nodeID != 0 {
return conn.WithContextModifier(cc, func(ctx context.Context) context.Context {
return balancerContext.WithNodeID(ctx, nodeID)
})
} else {
return cc
}
}

func New(ctx context.Context, cc grpc.ClientConnInterface, cfg *config.Config) *Client {
onDone := trace.QueryOnNew(cfg.Trace(), &ctx,
stack.FunctionID("github.com/ydb-platform/ydb-go-sdk/v3/internal/query.New"),
Expand Down Expand Up @@ -556,7 +545,7 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, cfg *config.Config) *
defer cancelCreate()

s, err := createSession(createCtx, client,
session.WithConn(modifyConn(cc, nodeID)),
session.WithConn(conn.ModifyConn(cc, nodeID)),
session.WithDeleteTimeout(cfg.SessionDeleteTimeout()),
session.WithTrace(cfg.Trace()),
)
Expand Down
9 changes: 1 addition & 8 deletions internal/table/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ package table

import (
"context"

"github.com/jonboulle/clockwork"
"github.com/ydb-platform/ydb-go-genproto/Ydb_Table_V1"
"google.golang.org/grpc"

"github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/conn"
balancerContext "github.com/ydb-platform/ydb-go-sdk/v3/internal/endpoint"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/pool"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/stack"
"github.com/ydb-platform/ydb-go-sdk/v3/internal/table/config"
Expand Down Expand Up @@ -43,12 +41,7 @@ func New(ctx context.Context, cc grpc.ClientConnInterface, config *config.Config
pool.WithCloseItemTimeout[*session, session](config.DeleteTimeout()),
pool.WithClock[*session, session](config.Clock()),
pool.WithCreateItemFunc[*session, session](func(ctx context.Context, nodeId uint32) (*session, error) {
if nodeId != 0 {
cc = conn.WithContextModifier(cc, func(ctx context.Context) context.Context {
return balancerContext.WithNodeID(ctx, nodeId)
})
}
return newSession(ctx, cc, config)
return newSession(ctx, conn.ModifyConn(cc, nodeId), config)
}),
pool.WithTrace[*session, session](&pool.Trace{
OnNew: func(ctx *context.Context, call stack.Caller) func(limit int) {
Expand Down
2 changes: 1 addition & 1 deletion internal/table/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type sessionPool interface {
closer.Closer

Stats() pool.Stats
With(ctx context.Context, f func(ctx context.Context, s *session) error, preferredNodeID uint32, opts ...retry.Option) error
With(ctx context.Context, f func(ctx context.Context, s *session) error, nodeID uint32, opts ...retry.Option) error
}

func do(
Expand Down
17 changes: 8 additions & 9 deletions retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ import (
type retryOperation func(context.Context) (err error)

type retryOptions struct {
label string
call call
trace *trace.Retry
idempotent bool
stackTrace bool
fastBackoff backoff.Backoff
slowBackoff backoff.Backoff
budget budget.Budget
preferredNodeID uint32
label string
call call
trace *trace.Retry
idempotent bool
stackTrace bool
fastBackoff backoff.Backoff
slowBackoff backoff.Backoff
budget budget.Budget

panicCallback func(e interface{})
}
Expand Down

0 comments on commit a04d2be

Please sign in to comment.