Skip to content

Commit 862d8f4

Browse files
committed
refactoring of retry budget sources
1 parent 2a635d1 commit 862d8f4

File tree

25 files changed

+112
-128
lines changed

25 files changed

+112
-128
lines changed

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
balancerConfig "github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer/config"
1313
"github.com/ydb-platform/ydb-go-sdk/v3/internal/config"
1414
"github.com/ydb-platform/ydb-go-sdk/v3/internal/meta"
15-
"github.com/ydb-platform/ydb-go-sdk/v3/internal/retry"
15+
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
1616
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
1717
)
1818

@@ -159,9 +159,9 @@ func WithTrace(t trace.Driver, opts ...trace.DriverComposeOption) Option { //nol
159159
}
160160

161161
// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
162-
func WithRetryLimiter(l retry.Budget) Option {
162+
func WithRetryBudget(b budget.Budget) Option {
163163
return func(c *Config) {
164-
config.SetRetryLimiter(&c.Common, l)
164+
config.SetRetryBudget(&c.Common, b)
165165
}
166166
}
167167

internal/balancer/balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (b *Balancer) clusterDiscovery(ctx context.Context) (err error) {
8989
},
9090
retry.WithIdempotent(true),
9191
retry.WithTrace(b.driverConfig.TraceRetry()),
92-
retry.WithBudget(b.driverConfig.RetryLimiter()),
92+
retry.WithBudget(b.driverConfig.RetryBudget()),
9393
)
9494
}
9595

internal/config/config.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ package config
33
import (
44
"time"
55

6-
retry2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/retry"
7-
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
6+
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
87
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
98
)
109

11-
var defaultRetryLimiter = retry.Budget(-1)
10+
var defaultRetryBudget = budget.New(-1)
1211

1312
type Common struct {
1413
operationTimeout time.Duration
1514
operationCancelAfter time.Duration
1615
disableAutoRetry bool
1716
traceRetry trace.Retry
18-
retryLimiter retry2.Budget
17+
retryBudget budget.Budget
1918

2019
panicCallback func(e interface{})
2120
}
@@ -53,12 +52,12 @@ func (c *Common) TraceRetry() *trace.Retry {
5352
return &c.traceRetry
5453
}
5554

56-
func (c *Common) RetryLimiter() retry2.Budget {
57-
if c.retryLimiter == nil {
58-
return defaultRetryLimiter
55+
func (c *Common) RetryBudget() budget.Budget {
56+
if c.retryBudget == nil {
57+
return defaultRetryBudget
5958
}
6059

61-
return c.retryLimiter
60+
return c.retryBudget
6261
}
6362

6463
// SetOperationTimeout define the maximum amount of time a YDB server will process
@@ -95,6 +94,6 @@ func SetTraceRetry(c *Common, t *trace.Retry, opts ...trace.RetryComposeOption)
9594
c.traceRetry = *c.traceRetry.Compose(t, opts...)
9695
}
9796

98-
func SetRetryLimiter(c *Common, l retry2.Budget) {
99-
c.retryLimiter = l
97+
func SetRetryBudget(c *Common, b budget.Budget) {
98+
c.retryBudget = b
10099
}

internal/coordination/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (c *Client) CreateNode(ctx context.Context, path string, config coordinatio
117117
retry.WithStackTrace(),
118118
retry.WithIdempotent(true),
119119
retry.WithTrace(c.config.TraceRetry()),
120-
retry.WithBudget(c.config.RetryLimiter()),
120+
retry.WithBudget(c.config.RetryBudget()),
121121
)
122122
}
123123

@@ -150,7 +150,7 @@ func (c *Client) AlterNode(ctx context.Context, path string, config coordination
150150
retry.WithStackTrace(),
151151
retry.WithIdempotent(true),
152152
retry.WithTrace(c.config.TraceRetry()),
153-
retry.WithBudget(c.config.RetryLimiter()),
153+
retry.WithBudget(c.config.RetryBudget()),
154154
)
155155
}
156156

@@ -211,7 +211,7 @@ func (c *Client) DropNode(ctx context.Context, path string) (finalErr error) {
211211
retry.WithStackTrace(),
212212
retry.WithIdempotent(true),
213213
retry.WithTrace(c.config.TraceRetry()),
214-
retry.WithBudget(c.config.RetryLimiter()),
214+
retry.WithBudget(c.config.RetryBudget()),
215215
)
216216
}
217217

@@ -271,7 +271,7 @@ func (c *Client) DescribeNode(
271271
retry.WithStackTrace(),
272272
retry.WithIdempotent(true),
273273
retry.WithTrace(c.config.TraceRetry()),
274-
retry.WithBudget(c.config.RetryLimiter()),
274+
retry.WithBudget(c.config.RetryBudget()),
275275
)
276276
if err != nil {
277277
return nil, nil, xerrors.WithStackTrace(err)

internal/query/options/retry.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package options
22

33
import (
44
"github.com/ydb-platform/ydb-go-sdk/v3/internal/query/tx"
5-
retry2 "github.com/ydb-platform/ydb-go-sdk/v3/internal/retry"
65
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
6+
"github.com/ydb-platform/ydb-go-sdk/v3/retry/budget"
77
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
88
)
99

@@ -96,8 +96,8 @@ func WithTrace(t *trace.Query) traceOption {
9696
return traceOption{t: t}
9797
}
9898

99-
func WithBudget(l retry2.Budget) retryOptionsOption {
100-
return []retry.Option{retry.WithBudget(l)}
99+
func WithRetryBudget(b budget.Budget) retryOptionsOption {
100+
return []retry.Option{retry.WithBudget(b)}
101101
}
102102

103103
func ParseDoOpts(t *trace.Query, opts ...DoOption) (s *doSettings) {

internal/ratelimiter/client.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (c *Client) CreateResource(
6363
retry.WithStackTrace(),
6464
retry.WithIdempotent(true),
6565
retry.WithTrace(c.config.TraceRetry()),
66-
retry.WithBudget(c.config.RetryLimiter()),
66+
retry.WithBudget(c.config.RetryBudget()),
6767
)
6868
}
6969

@@ -113,7 +113,7 @@ func (c *Client) AlterResource(
113113
retry.WithStackTrace(),
114114
retry.WithIdempotent(true),
115115
retry.WithTrace(c.config.TraceRetry()),
116-
retry.WithBudget(c.config.RetryLimiter()),
116+
retry.WithBudget(c.config.RetryBudget()),
117117
)
118118
}
119119

@@ -163,7 +163,7 @@ func (c *Client) DropResource(
163163
retry.WithStackTrace(),
164164
retry.WithIdempotent(true),
165165
retry.WithTrace(c.config.TraceRetry()),
166-
retry.WithBudget(c.config.RetryLimiter()),
166+
retry.WithBudget(c.config.RetryBudget()),
167167
)
168168
}
169169

@@ -209,7 +209,7 @@ func (c *Client) ListResource(
209209
retry.WithIdempotent(true),
210210
retry.WithStackTrace(),
211211
retry.WithTrace(c.config.TraceRetry()),
212-
retry.WithBudget(c.config.RetryLimiter()),
212+
retry.WithBudget(c.config.RetryBudget()),
213213
)
214214

215215
return list, err
@@ -269,7 +269,7 @@ func (c *Client) DescribeResource(
269269
retry.WithIdempotent(true),
270270
retry.WithStackTrace(),
271271
retry.WithTrace(c.config.TraceRetry()),
272-
retry.WithBudget(c.config.RetryLimiter()),
272+
retry.WithBudget(c.config.RetryBudget()),
273273
)
274274

275275
return
@@ -338,7 +338,7 @@ func (c *Client) AcquireResource(
338338
return retry.Retry(ctx, call,
339339
retry.WithStackTrace(),
340340
retry.WithTrace(c.config.TraceRetry()),
341-
retry.WithBudget(c.config.RetryLimiter()),
341+
retry.WithBudget(c.config.RetryBudget()),
342342
)
343343
}
344344

internal/scheme/client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (c *Client) MakeDirectory(ctx context.Context, path string) (finalErr error
6464
retry.WithStackTrace(),
6565
retry.WithIdempotent(true),
6666
retry.WithTrace(c.config.TraceRetry()),
67-
retry.WithBudget(c.config.RetryLimiter()),
67+
retry.WithBudget(c.config.RetryBudget()),
6868
)
6969
}
7070

@@ -104,7 +104,7 @@ func (c *Client) RemoveDirectory(ctx context.Context, path string) (finalErr err
104104
retry.WithStackTrace(),
105105
retry.WithIdempotent(true),
106106
retry.WithTrace(c.config.TraceRetry()),
107-
retry.WithBudget(c.config.RetryLimiter()),
107+
retry.WithBudget(c.config.RetryBudget()),
108108
)
109109
}
110110

@@ -146,7 +146,7 @@ func (c *Client) ListDirectory(ctx context.Context, path string) (d scheme.Direc
146146
retry.WithIdempotent(true),
147147
retry.WithStackTrace(),
148148
retry.WithTrace(c.config.TraceRetry()),
149-
retry.WithBudget(c.config.RetryLimiter()),
149+
retry.WithBudget(c.config.RetryBudget()),
150150
)
151151

152152
return d, xerrors.WithStackTrace(err)
@@ -210,7 +210,7 @@ func (c *Client) DescribePath(ctx context.Context, path string) (e scheme.Entry,
210210
retry.WithIdempotent(true),
211211
retry.WithStackTrace(),
212212
retry.WithTrace(c.config.TraceRetry()),
213-
retry.WithBudget(c.config.RetryLimiter()),
213+
retry.WithBudget(c.config.RetryBudget()),
214214
)
215215

216216
return e, xerrors.WithStackTrace(err)
@@ -272,7 +272,7 @@ func (c *Client) ModifyPermissions(
272272
retry.WithStackTrace(),
273273
retry.WithIdempotent(true),
274274
retry.WithTrace(c.config.TraceRetry()),
275-
retry.WithBudget(c.config.RetryLimiter()),
275+
retry.WithBudget(c.config.RetryBudget()),
276276
)
277277
}
278278

internal/scripting/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (c *Client) Execute(
6060
err = retry.Retry(ctx, call,
6161
retry.WithStackTrace(),
6262
retry.WithTrace(c.config.TraceRetry()),
63-
retry.WithBudget(c.config.RetryLimiter()),
63+
retry.WithBudget(c.config.RetryBudget()),
6464
)
6565

6666
return r, xerrors.WithStackTrace(err)
@@ -140,7 +140,7 @@ func (c *Client) Explain(
140140
retry.WithStackTrace(),
141141
retry.WithIdempotent(true),
142142
retry.WithTrace(c.config.TraceRetry()),
143-
retry.WithBudget(c.config.RetryLimiter()),
143+
retry.WithBudget(c.config.RetryBudget()),
144144
)
145145

146146
return e, xerrors.WithStackTrace(err)
@@ -215,7 +215,7 @@ func (c *Client) StreamExecute(
215215
err = retry.Retry(ctx, call,
216216
retry.WithStackTrace(),
217217
retry.WithTrace(c.config.TraceRetry()),
218-
retry.WithBudget(c.config.RetryLimiter()),
218+
retry.WithBudget(c.config.RetryBudget()),
219219
)
220220

221221
return r, xerrors.WithStackTrace(err)

internal/table/retry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (c *Client) retryOptions(opts ...table.Option) *table.Options {
9999
),
100100
RetryOptions: []retry.Option{
101101
retry.WithTrace(c.config.TraceRetry()),
102-
retry.WithBudget(c.config.RetryLimiter()),
102+
retry.WithBudget(c.config.RetryBudget()),
103103
},
104104
}
105105
for _, opt := range opts {

internal/topic/topicclientinternal/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (c *Client) Alter(ctx context.Context, path string, opts ...topicoptions.Al
8787
return retry.Retry(ctx, call,
8888
retry.WithIdempotent(true),
8989
retry.WithTrace(c.cfg.TraceRetry()),
90-
retry.WithBudget(c.cfg.RetryLimiter()),
90+
retry.WithBudget(c.cfg.RetryBudget()),
9191
)
9292
}
9393

@@ -120,7 +120,7 @@ func (c *Client) Create(
120120
return retry.Retry(ctx, call,
121121
retry.WithIdempotent(true),
122122
retry.WithTrace(c.cfg.TraceRetry()),
123-
retry.WithBudget(c.cfg.RetryLimiter()),
123+
retry.WithBudget(c.cfg.RetryBudget()),
124124
)
125125
}
126126

@@ -158,7 +158,7 @@ func (c *Client) Describe(
158158
err = retry.Retry(ctx, call,
159159
retry.WithIdempotent(true),
160160
retry.WithTrace(c.cfg.TraceRetry()),
161-
retry.WithBudget(c.cfg.RetryLimiter()),
161+
retry.WithBudget(c.cfg.RetryBudget()),
162162
)
163163
} else {
164164
err = call(ctx)
@@ -195,7 +195,7 @@ func (c *Client) Drop(ctx context.Context, path string, opts ...topicoptions.Dro
195195
return retry.Retry(ctx, call,
196196
retry.WithIdempotent(true),
197197
retry.WithTrace(c.cfg.TraceRetry()),
198-
retry.WithBudget(c.cfg.RetryLimiter()),
198+
retry.WithBudget(c.cfg.RetryBudget()),
199199
)
200200
}
201201

0 commit comments

Comments
 (0)