File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Expand file tree Collapse file tree 2 files changed +53
-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/internal/topic"
6+ "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
7+ )
8+
9+ func ExampleWithReaderCheckRetryErrorFunction () {
10+ var db ydb.Connection
11+
12+ reader , err := db .Topic ().StartReader (
13+ "consumer" ,
14+ topicoptions .ReadTopic ("topic" ),
15+ topicoptions .WithReaderCheckRetryErrorFunction (
16+ func (errInfo topic.PublicCheckErrorRetryArgs ) topic.PublicCheckRetryResult {
17+ // Retry not found operations
18+ if ydb .IsOperationErrorNotFoundError (errInfo .Error ) {
19+ return topicoptions .CheckErrorRetryDecisionRetry
20+ }
21+
22+ // and use default behavior for all other errors
23+ return topicoptions .CheckErrorRetryDecisionDefault
24+ }),
25+ )
26+ _ , _ = reader , err
27+ }
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/internal/topic"
6+ "github.com/ydb-platform/ydb-go-sdk/v3/topic/topicoptions"
7+ )
8+
9+ func ExampleWithWriterCheckRetryErrorFunction () {
10+ var db ydb.Connection
11+ writer , err := db .Topic ().StartWriter (
12+ "" ,
13+ "" ,
14+ topicoptions .WithWriterCheckRetryErrorFunction (
15+ func (errInfo topic.PublicCheckErrorRetryArgs ) topic.PublicCheckRetryResult {
16+ // Retry for all transport errors
17+ if ydb .IsTransportError (errInfo .Error ) {
18+ return topicoptions .CheckErrorRetryDecisionRetry
19+ }
20+
21+ // and use default behavior for all other errors
22+ return topicoptions .CheckErrorRetryDecisionDefault
23+ }),
24+ )
25+ _ , _ = writer , err
26+ }
You can’t perform that action at this time.
0 commit comments