github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/topic/topicoptions/topicoptions_topic.go (about) 1 package topicoptions 2 3 import ( 4 "time" 5 6 "github.com/ydb-platform/ydb-go-sdk/v3/internal/config" 7 "github.com/ydb-platform/ydb-go-sdk/v3/internal/topic" 8 "github.com/ydb-platform/ydb-go-sdk/v3/trace" 9 ) 10 11 // TopicOption 12 // 13 // # Experimental 14 // 15 // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release. 16 type TopicOption func(c *topic.Config) 17 18 // WithTrace defines trace over persqueue client calls 19 // 20 // # Experimental 21 // 22 // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release. 23 func WithTrace(trace trace.Topic, opts ...trace.TopicComposeOption) TopicOption { //nolint:gocritic 24 return func(c *topic.Config) { 25 c.Trace = c.Trace.Compose(&trace, opts...) 26 } 27 } 28 29 // WithOperationTimeout set the maximum amount of time a YDB server will process 30 // an operation. After timeout exceeds YDB will try to cancel operation and 31 // regardless of the cancellation appropriate error will be returned to 32 // the client. 33 // If OperationTimeout is zero then no timeout is used. 34 // 35 // # Experimental 36 // 37 // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release. 38 func WithOperationTimeout(operationTimeout time.Duration) TopicOption { 39 return func(c *topic.Config) { 40 config.SetOperationTimeout(&c.Common, operationTimeout) 41 } 42 } 43 44 // WithOperationCancelAfter set the maximum amount of time a YDB server will process an 45 // operation. After timeout exceeds YDB will try to cancel operation and if 46 // it succeeds appropriate error will be returned to the client; otherwise 47 // processing will be continued. 48 // If OperationCancelAfter is zero then no timeout is used. 49 // 50 // # Experimental 51 // 52 // Notice: This API is EXPERIMENTAL and may be changed or removed in a later release. 53 func WithOperationCancelAfter(operationCancelAfter time.Duration) TopicOption { 54 return func(c *topic.Config) { 55 config.SetOperationCancelAfter(&c.Common, operationCancelAfter) 56 } 57 }