github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/scripting/config/config.go (about)

     1  package config
     2  
     3  import (
     4  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/config"
     5  	"github.com/ydb-platform/ydb-go-sdk/v3/trace"
     6  )
     7  
     8  type Config struct {
     9  	config.Common
    10  
    11  	trace *trace.Scripting
    12  }
    13  
    14  // Trace defines trace over scripting client calls
    15  func (c Config) Trace() *trace.Scripting {
    16  	return c.trace
    17  }
    18  
    19  type Option func(c *Config)
    20  
    21  // WithTrace appends scripting trace to early added traces
    22  func WithTrace(trace trace.Scripting, opts ...trace.ScriptingComposeOption) Option {
    23  	return func(c *Config) {
    24  		c.trace = c.trace.Compose(&trace, opts...)
    25  	}
    26  }
    27  
    28  // With applies common configuration params
    29  func With(config config.Common) Option {
    30  	return func(c *Config) {
    31  		c.Common = config
    32  	}
    33  }
    34  
    35  func New(opts ...Option) Config {
    36  	c := Config{
    37  		trace: &trace.Scripting{},
    38  	}
    39  	for _, o := range opts {
    40  		if o != nil {
    41  			o(&c)
    42  		}
    43  	}
    44  
    45  	return c
    46  }