github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicoptions/topicoptions_reader_example_test.go (about)

     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.Driver
    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  }