github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicoptions/topicoptions_writer_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 ExampleWithWriterCheckRetryErrorFunction() {
     9  	var db *ydb.Driver
    10  	writer, err := db.Topic().StartWriter(
    11  		"",
    12  		topicoptions.WithWriterCheckRetryErrorFunction(
    13  			func(errInfo topicoptions.CheckErrorRetryArgs) topicoptions.CheckErrorRetryResult {
    14  				// Retry for all transport errors
    15  				if ydb.IsTransportError(errInfo.Error) {
    16  					return topicoptions.CheckErrorRetryDecisionRetry
    17  				}
    18  
    19  				// and use default behavior for all other errors
    20  				return topicoptions.CheckErrorRetryDecisionDefault
    21  			}),
    22  	)
    23  	_, _ = writer, err
    24  }