Skip to content

Commit

Permalink
* Renamed query.WithPoolID() into query.WithResourcePool()
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Oct 22, 2024
1 parent 9be2f13 commit eefabac
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
6 changes: 3 additions & 3 deletions internal/query/execute_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type executeSettings interface {
Params() *params.Parameters
CallOptions() []grpc.CallOption
RetryOpts() []retry.Option
PoolID() string
ResourcePool() string
}

type executeScriptConfig interface {
Expand All @@ -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()
Expand All @@ -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()
}
Expand Down
18 changes: 9 additions & 9 deletions internal/query/options/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,7 +50,7 @@ type (
// execute options
callOptionsOption []grpc.CallOption
txCommitOption struct{}
poolID string
resourcePool string
parametersOption params.Parameters
txControlOption tx.Control
syntaxOption = Syntax
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
16 changes: 8 additions & 8 deletions internal/query/options/execute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
} {
Expand All @@ -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())
Expand Down
7 changes: 5 additions & 2 deletions query/execute_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit eefabac

Please sign in to comment.