github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/query/do_options.go (about)

     1  package query
     2  
     3  import (
     4  	"github.com/ydb-platform/ydb-go-sdk/v3/retry"
     5  	"github.com/ydb-platform/ydb-go-sdk/v3/trace"
     6  )
     7  
     8  var (
     9  	_ DoOption = idempotentOption{}
    10  	_ DoOption = traceOption{}
    11  )
    12  
    13  func (idempotentOption) applyDoOption(opts *DoOptions) {
    14  	opts.Idempotent = true
    15  	opts.RetryOptions = append(opts.RetryOptions, retry.WithIdempotent(true))
    16  }
    17  
    18  func (opt traceOption) applyDoOption(o *DoOptions) {
    19  	o.Trace = o.Trace.Compose(opt.t)
    20  }
    21  
    22  func NewDoOptions(opts ...DoOption) (doOptions DoOptions) {
    23  	doOptions.Trace = &trace.Query{}
    24  
    25  	for _, opt := range opts {
    26  		opt.applyDoOption(&doOptions)
    27  	}
    28  
    29  	return doOptions
    30  }