Skip to content

Commit 55ed91d

Browse files
committed
add internal retryer's to lazy coordination client
1 parent b910d2b commit 55ed91d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

internal/lazy/coordiantion.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/ydb-platform/ydb-go-sdk/v3/coordination"
88
builder "github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination"
99
"github.com/ydb-platform/ydb-go-sdk/v3/internal/db"
10+
"github.com/ydb-platform/ydb-go-sdk/v3/retry"
1011
"github.com/ydb-platform/ydb-go-sdk/v3/scheme"
1112
)
1213

@@ -24,29 +25,39 @@ func Coordination(db db.Connection) coordination.Client {
2425

2526
func (c *lazyCoordination) CreateNode(ctx context.Context, path string, config coordination.Config) (err error) {
2627
c.init()
27-
return c.client.CreateNode(ctx, path, config)
28+
return retry.Retry(ctx, false, func(ctx context.Context) (err error) {
29+
return c.client.CreateNode(ctx, path, config)
30+
})
2831
}
2932

3033
func (c *lazyCoordination) AlterNode(ctx context.Context, path string, config coordination.Config) (err error) {
3134
c.init()
32-
return c.client.AlterNode(ctx, path, config)
35+
return retry.Retry(ctx, false, func(ctx context.Context) (err error) {
36+
return c.client.AlterNode(ctx, path, config)
37+
})
3338
}
3439

3540
func (c *lazyCoordination) DropNode(ctx context.Context, path string) (err error) {
3641
c.init()
37-
return c.client.DropNode(ctx, path)
42+
return retry.Retry(ctx, false, func(ctx context.Context) (err error) {
43+
return c.client.DropNode(ctx, path)
44+
})
3845
}
3946

4047
func (c *lazyCoordination) DescribeNode(
4148
ctx context.Context,
4249
path string,
4350
) (
44-
_ *scheme.Entry,
45-
_ *coordination.Config,
51+
entry *scheme.Entry,
52+
config *coordination.Config,
4653
err error,
4754
) {
4855
c.init()
49-
return c.client.DescribeNode(ctx, path)
56+
err = retry.Retry(ctx, false, func(ctx context.Context) (err error) {
57+
entry, config, err = c.client.DescribeNode(ctx, path)
58+
return err
59+
})
60+
return entry, config, err
5061
}
5162

5263
func (c *lazyCoordination) Close(ctx context.Context) error {

0 commit comments

Comments
 (0)