github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/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: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    14  type TopicOption func(c *topic.Config)
    15  
    16  // WithTrace defines trace over persqueue client calls
    17  //
    18  // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    19  func WithTrace(trace trace.Topic, opts ...trace.TopicComposeOption) TopicOption { //nolint:gocritic
    20  	return func(c *topic.Config) {
    21  		c.Trace = c.Trace.Compose(&trace, opts...)
    22  	}
    23  }
    24  
    25  // WithOperationTimeout set the maximum amount of time a YDB server will process
    26  // an operation. After timeout exceeds YDB will try to cancel operation and
    27  // regardless of the cancellation appropriate error will be returned to
    28  // the client.
    29  // If OperationTimeout is zero then no timeout is used.
    30  //
    31  // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    32  func WithOperationTimeout(operationTimeout time.Duration) TopicOption {
    33  	return func(c *topic.Config) {
    34  		config.SetOperationTimeout(&c.Common, operationTimeout)
    35  	}
    36  }
    37  
    38  // WithOperationCancelAfter set the maximum amount of time a YDB server will process an
    39  // operation. After timeout exceeds YDB will try to cancel operation and if
    40  // it succeeds appropriate error will be returned to the client; otherwise
    41  // processing will be continued.
    42  // If OperationCancelAfter is zero then no timeout is used.
    43  //
    44  // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
    45  func WithOperationCancelAfter(operationCancelAfter time.Duration) TopicOption {
    46  	return func(c *topic.Config) {
    47  		config.SetOperationCancelAfter(&c.Common, operationCancelAfter)
    48  	}
    49  }