From eefabac076113d78be72fb040f07cbebca8bd1b5 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Wed, 23 Oct 2024 01:00:31 +0300 Subject: [PATCH] * Renamed `query.WithPoolID()` into `query.WithResourcePool()` --- CHANGELOG.md | 4 +++- internal/query/execute_query.go | 6 +++--- internal/query/options/execute.go | 18 +++++++++--------- internal/query/options/execute_test.go | 16 ++++++++-------- query/execute_options.go | 7 +++++-- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15fe13b39..b5e5dd7a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ +* Renamed `query.WithPoolID()` into `query.WithResourcePool()` + ## v3.85.2 -* Added `query.WithPoolID()` execute option +* Added experimental `query.WithPoolID()` execute option for define resource pool for execute query ## v3.85.1 * Added `spans.Retry` constructor of `trace.Retry` diff --git a/internal/query/execute_query.go b/internal/query/execute_query.go index 969ac5b93..1fec9e6a2 100644 --- a/internal/query/execute_query.go +++ b/internal/query/execute_query.go @@ -30,7 +30,7 @@ type executeSettings interface { Params() *params.Parameters CallOptions() []grpc.CallOption RetryOpts() []retry.Option - PoolID() string + ResourcePool() string } type executeScriptConfig interface { @@ -57,7 +57,7 @@ func executeQueryScriptRequest(a *allocator.Allocator, q string, cfg executeScri Parameters: cfg.Params().ToYDB(a), StatsMode: Ydb_Query.StatsMode(cfg.StatsMode()), ResultsTtl: durationpb.New(cfg.ResultsTTL()), - PoolId: cfg.PoolID(), + PoolId: cfg.ResourcePool(), } return request, cfg.CallOptions() @@ -76,7 +76,7 @@ func executeQueryRequest(a *allocator.Allocator, sessionID, q string, cfg execut request.Parameters = cfg.Params().ToYDB(a) request.StatsMode = Ydb_Query.StatsMode(cfg.StatsMode()) request.ConcurrentResultSets = false - request.PoolId = cfg.PoolID() + request.PoolId = cfg.ResourcePool() return request, cfg.CallOptions() } diff --git a/internal/query/options/execute.go b/internal/query/options/execute.go index 4cfe1957a..76110d93a 100644 --- a/internal/query/options/execute.go +++ b/internal/query/options/execute.go @@ -31,7 +31,7 @@ type ( params params.Parameters execMode ExecMode statsMode StatsMode - poolID string + resourcePool string statsCallback func(queryStats stats.QueryStats) callOptions []grpc.CallOption txControl *tx.Control @@ -50,7 +50,7 @@ type ( // execute options callOptionsOption []grpc.CallOption txCommitOption struct{} - poolID string + resourcePool string parametersOption params.Parameters txControlOption tx.Control syntaxOption = Syntax @@ -61,8 +61,8 @@ type ( execModeOption = ExecMode ) -func (poolID poolID) applyExecuteOption(s *executeSettings) { - s.poolID = string(poolID) +func (poolID resourcePool) applyExecuteOption(s *executeSettings) { + s.resourcePool = string(poolID) } func (s *executeSettings) RetryOpts() []retry.Option { @@ -163,8 +163,8 @@ func (s *executeSettings) StatsMode() StatsMode { return s.statsMode } -func (s *executeSettings) PoolID() string { - return s.poolID +func (s *executeSettings) ResourcePool() string { + return s.resourcePool } func (s *executeSettings) Params() *params.Parameters { @@ -186,15 +186,15 @@ var ( _ Execute = StatsMode(0) _ Execute = txCommitOption{} _ Execute = (*txControlOption)(nil) - _ Execute = poolID("") + _ Execute = resourcePool("") ) func WithCommit() txCommitOption { return txCommitOption{} } -func WithPoolID(id string) poolID { - return poolID(id) +func WithResourcePool(id string) resourcePool { + return resourcePool(id) } func WithExecMode(mode ExecMode) execModeOption { diff --git a/internal/query/options/execute_test.go b/internal/query/options/execute_test.go index b0af4bb80..19603e6f0 100644 --- a/internal/query/options/execute_test.go +++ b/internal/query/options/execute_test.go @@ -120,16 +120,16 @@ func TestExecuteSettings(t *testing.T) { }, }, { - name: "WithPoolID", + name: "WithResourcePool", txOpts: []Execute{ - WithPoolID("test-pool-id"), + WithResourcePool("test-pool-id"), }, settings: executeSettings{ - execMode: ExecModeExecute, - statsMode: StatsModeNone, - txControl: internal.NewControl(internal.WithTxID("")), - syntax: SyntaxYQL, - poolID: "test-pool-id", + execMode: ExecModeExecute, + statsMode: StatsModeNone, + txControl: internal.NewControl(internal.WithTxID("")), + syntax: SyntaxYQL, + resourcePool: "test-pool-id", }, }, } { @@ -144,7 +144,7 @@ func TestExecuteSettings(t *testing.T) { require.Equal(t, tt.settings.Syntax(), settings.Syntax()) require.Equal(t, tt.settings.ExecMode(), settings.ExecMode()) require.Equal(t, tt.settings.StatsMode(), settings.StatsMode()) - require.Equal(t, tt.settings.PoolID(), settings.PoolID()) + require.Equal(t, tt.settings.ResourcePool(), settings.ResourcePool()) require.Equal(t, tt.settings.TxControl().ToYDB(a).String(), settings.TxControl().ToYDB(a).String()) require.Equal(t, tt.settings.Params().ToYDB(a), settings.Params().ToYDB(a)) require.Equal(t, tt.settings.CallOptions(), settings.CallOptions()) diff --git a/query/execute_options.go b/query/execute_options.go index 031648c62..a8d2ac770 100644 --- a/query/execute_options.go +++ b/query/execute_options.go @@ -59,6 +59,9 @@ func WithCallOptions(opts ...grpc.CallOption) options.Execute { return options.WithCallOptions(opts...) } -func WithPoolID(id string) options.Execute { - return options.WithPoolID(id) +// WithResourcePool is an option for define resource pool for execute query +// +// Read more https://ydb.tech/docs/ru/dev/resource-consumption-management +func WithResourcePool(id string) options.Execute { + return options.WithResourcePool(id) }