File tree Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Expand file tree Collapse file tree 2 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package topicoptions_test
2+
3+ import (
4+ "github.com/ydb-platform/ydb-go-sdk/v3"
5+ "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
6+ )
7+
8+ func ExampleWithReaderCheckRetryErrorFunction () {
9+ var db ydb.Connection
10+
11+ reader , err := db .Topic ().StartReader (
12+ "consumer" ,
13+ topicoptions .ReadTopic ("topic" ),
14+ topicoptions .WithReaderCheckRetryErrorFunction (
15+ func (errInfo topicoptions.CheckErrorRetryArgs ) topicoptions.CheckErrorRetryResult {
16+ // Retry not found operations
17+ if ydb .IsOperationErrorNotFoundError (errInfo .Error ) {
18+ return topicoptions .CheckErrorRetryDecisionRetry
19+ }
20+
21+ // and use default behavior for all other errors
22+ return topicoptions .CheckErrorRetryDecisionDefault
23+ }),
24+ )
25+ _ , _ = reader , err
26+ }
Original file line number Diff line number Diff line change 1+ package topicoptions_test
2+
3+ import (
4+ "github.com/ydb-platform/ydb-go-sdk/v3"
5+ "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
6+ )
7+
8+ func ExampleWithWriterCheckRetryErrorFunction () {
9+ var db ydb.Connection
10+ writer , err := db .Topic ().StartWriter (
11+ "" ,
12+ "" ,
13+ topicoptions .WithWriterCheckRetryErrorFunction (
14+ func (errInfo topicoptions.CheckErrorRetryArgs ) topicoptions.CheckErrorRetryResult {
15+ // Retry for all transport errors
16+ if ydb .IsTransportError (errInfo .Error ) {
17+ return topicoptions .CheckErrorRetryDecisionRetry
18+ }
19+
20+ // and use default behavior for all other errors
21+ return topicoptions .CheckErrorRetryDecisionDefault
22+ }),
23+ )
24+ _ , _ = writer , err
25+ }
You can’t perform that action at this time.
0 commit comments