Skip to content

Commit 8e1a2b4

Browse files
authored
Merge pull request #1522 from ydb-platform/resource-pool
* Renamed `query.WithPoolID()` into `query.WithResourcePool()`
2 parents 9be2f13 + eefabac commit 8e1a2b4

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
* Renamed `query.WithPoolID()` into `query.WithResourcePool()`
2+
13
## v3.85.2
2-
* Added `query.WithPoolID()` execute option
4+
* Added experimental `query.WithPoolID()` execute option for define resource pool for execute query
35

46
## v3.85.1
57
* Added `spans.Retry` constructor of `trace.Retry`

internal/query/execute_query.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type executeSettings interface {
3030
Params() *params.Parameters
3131
CallOptions() []grpc.CallOption
3232
RetryOpts() []retry.Option
33-
PoolID() string
33+
ResourcePool() string
3434
}
3535

3636
type executeScriptConfig interface {
@@ -57,7 +57,7 @@ func executeQueryScriptRequest(a *allocator.Allocator, q string, cfg executeScri
5757
Parameters: cfg.Params().ToYDB(a),
5858
StatsMode: Ydb_Query.StatsMode(cfg.StatsMode()),
5959
ResultsTtl: durationpb.New(cfg.ResultsTTL()),
60-
PoolId: cfg.PoolID(),
60+
PoolId: cfg.ResourcePool(),
6161
}
6262

6363
return request, cfg.CallOptions()
@@ -76,7 +76,7 @@ func executeQueryRequest(a *allocator.Allocator, sessionID, q string, cfg execut
7676
request.Parameters = cfg.Params().ToYDB(a)
7777
request.StatsMode = Ydb_Query.StatsMode(cfg.StatsMode())
7878
request.ConcurrentResultSets = false
79-
request.PoolId = cfg.PoolID()
79+
request.PoolId = cfg.ResourcePool()
8080

8181
return request, cfg.CallOptions()
8282
}

internal/query/options/execute.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type (
3131
params params.Parameters
3232
execMode ExecMode
3333
statsMode StatsMode
34-
poolID string
34+
resourcePool string
3535
statsCallback func(queryStats stats.QueryStats)
3636
callOptions []grpc.CallOption
3737
txControl *tx.Control
@@ -50,7 +50,7 @@ type (
5050
// execute options
5151
callOptionsOption []grpc.CallOption
5252
txCommitOption struct{}
53-
poolID string
53+
resourcePool string
5454
parametersOption params.Parameters
5555
txControlOption tx.Control
5656
syntaxOption = Syntax
@@ -61,8 +61,8 @@ type (
6161
execModeOption = ExecMode
6262
)
6363

64-
func (poolID poolID) applyExecuteOption(s *executeSettings) {
65-
s.poolID = string(poolID)
64+
func (poolID resourcePool) applyExecuteOption(s *executeSettings) {
65+
s.resourcePool = string(poolID)
6666
}
6767

6868
func (s *executeSettings) RetryOpts() []retry.Option {
@@ -163,8 +163,8 @@ func (s *executeSettings) StatsMode() StatsMode {
163163
return s.statsMode
164164
}
165165

166-
func (s *executeSettings) PoolID() string {
167-
return s.poolID
166+
func (s *executeSettings) ResourcePool() string {
167+
return s.resourcePool
168168
}
169169

170170
func (s *executeSettings) Params() *params.Parameters {
@@ -186,15 +186,15 @@ var (
186186
_ Execute = StatsMode(0)
187187
_ Execute = txCommitOption{}
188188
_ Execute = (*txControlOption)(nil)
189-
_ Execute = poolID("")
189+
_ Execute = resourcePool("")
190190
)
191191

192192
func WithCommit() txCommitOption {
193193
return txCommitOption{}
194194
}
195195

196-
func WithPoolID(id string) poolID {
197-
return poolID(id)
196+
func WithResourcePool(id string) resourcePool {
197+
return resourcePool(id)
198198
}
199199

200200
func WithExecMode(mode ExecMode) execModeOption {

internal/query/options/execute_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ func TestExecuteSettings(t *testing.T) {
120120
},
121121
},
122122
{
123-
name: "WithPoolID",
123+
name: "WithResourcePool",
124124
txOpts: []Execute{
125-
WithPoolID("test-pool-id"),
125+
WithResourcePool("test-pool-id"),
126126
},
127127
settings: executeSettings{
128-
execMode: ExecModeExecute,
129-
statsMode: StatsModeNone,
130-
txControl: internal.NewControl(internal.WithTxID("")),
131-
syntax: SyntaxYQL,
132-
poolID: "test-pool-id",
128+
execMode: ExecModeExecute,
129+
statsMode: StatsModeNone,
130+
txControl: internal.NewControl(internal.WithTxID("")),
131+
syntax: SyntaxYQL,
132+
resourcePool: "test-pool-id",
133133
},
134134
},
135135
} {
@@ -144,7 +144,7 @@ func TestExecuteSettings(t *testing.T) {
144144
require.Equal(t, tt.settings.Syntax(), settings.Syntax())
145145
require.Equal(t, tt.settings.ExecMode(), settings.ExecMode())
146146
require.Equal(t, tt.settings.StatsMode(), settings.StatsMode())
147-
require.Equal(t, tt.settings.PoolID(), settings.PoolID())
147+
require.Equal(t, tt.settings.ResourcePool(), settings.ResourcePool())
148148
require.Equal(t, tt.settings.TxControl().ToYDB(a).String(), settings.TxControl().ToYDB(a).String())
149149
require.Equal(t, tt.settings.Params().ToYDB(a), settings.Params().ToYDB(a))
150150
require.Equal(t, tt.settings.CallOptions(), settings.CallOptions())

query/execute_options.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ func WithCallOptions(opts ...grpc.CallOption) options.Execute {
5959
return options.WithCallOptions(opts...)
6060
}
6161

62-
func WithPoolID(id string) options.Execute {
63-
return options.WithPoolID(id)
62+
// WithResourcePool is an option for define resource pool for execute query
63+
//
64+
// Read more https://ydb.tech/docs/ru/dev/resource-consumption-management
65+
func WithResourcePool(id string) options.Execute {
66+
return options.WithResourcePool(id)
6467
}

0 commit comments

Comments
 (0)