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

     1  package config
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/config"
     7  )
     8  
     9  type Option func(*Config)
    10  
    11  // With applies common configuration params
    12  func With(config config.Common) Option {
    13  	return func(c *Config) {
    14  		c.Common = config
    15  	}
    16  }
    17  
    18  // WithSizeLimit defines upper bound of pooled sessions.
    19  // If sizeLimit is less than or equal to zero then the
    20  // DefaultPoolMaxSize variable is used as a limit.
    21  func WithSizeLimit(sizeLimit int) Option {
    22  	return func(c *Config) {
    23  		if sizeLimit > 0 {
    24  			c.sizeLimit = sizeLimit
    25  		}
    26  	}
    27  }
    28  
    29  // WithCreateSessionTimeout limits maximum time spent on Create session request
    30  // If createSessionTimeout is less than or equal to zero then no used timeout on create session request
    31  func WithCreateSessionTimeout(createSessionTimeout time.Duration) Option {
    32  	return func(c *Config) {
    33  		if createSessionTimeout > 0 {
    34  			c.createSessionTimeout = createSessionTimeout
    35  		} else {
    36  			c.createSessionTimeout = 0
    37  		}
    38  	}
    39  }
    40  
    41  // WithDeleteTimeout limits maximum time spent on Delete request
    42  // If deleteTimeout is less than or equal to zero then the DefaultPoolDeleteTimeout is used.
    43  func WithDeleteTimeout(deleteTimeout time.Duration) Option {
    44  	return func(c *Config) {
    45  		if deleteTimeout > 0 {
    46  			c.deleteTimeout = deleteTimeout
    47  		}
    48  	}
    49  }