-
Notifications
You must be signed in to change notification settings - Fork 245
/
zz_generated.connpool.options.go
111 lines (97 loc) · 3.63 KB
/
zz_generated.connpool.options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Code generated by github.com/ecordell/optgen. DO NOT EDIT.
package datastore
import (
defaults "github.com/creasty/defaults"
helpers "github.com/ecordell/optgen/helpers"
"time"
)
type ConnPoolConfigOption func(c *ConnPoolConfig)
// NewConnPoolConfigWithOptions creates a new ConnPoolConfig with the passed in options set
func NewConnPoolConfigWithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig {
c := &ConnPoolConfig{}
for _, o := range opts {
o(c)
}
return c
}
// NewConnPoolConfigWithOptionsAndDefaults creates a new ConnPoolConfig with the passed in options set starting from the defaults
func NewConnPoolConfigWithOptionsAndDefaults(opts ...ConnPoolConfigOption) *ConnPoolConfig {
c := &ConnPoolConfig{}
defaults.MustSet(c)
for _, o := range opts {
o(c)
}
return c
}
// ToOption returns a new ConnPoolConfigOption that sets the values from the passed in ConnPoolConfig
func (c *ConnPoolConfig) ToOption() ConnPoolConfigOption {
return func(to *ConnPoolConfig) {
to.MaxIdleTime = c.MaxIdleTime
to.MaxLifetime = c.MaxLifetime
to.MaxLifetimeJitter = c.MaxLifetimeJitter
to.MaxOpenConns = c.MaxOpenConns
to.MinOpenConns = c.MinOpenConns
to.HealthCheckInterval = c.HealthCheckInterval
}
}
// DebugMap returns a map form of ConnPoolConfig for debugging
func (c ConnPoolConfig) DebugMap() map[string]any {
debugMap := map[string]any{}
debugMap["MaxIdleTime"] = helpers.DebugValue(c.MaxIdleTime, false)
debugMap["MaxLifetime"] = helpers.DebugValue(c.MaxLifetime, false)
debugMap["MaxLifetimeJitter"] = helpers.DebugValue(c.MaxLifetimeJitter, false)
debugMap["MaxOpenConns"] = helpers.DebugValue(c.MaxOpenConns, false)
debugMap["MinOpenConns"] = helpers.DebugValue(c.MinOpenConns, false)
debugMap["HealthCheckInterval"] = helpers.DebugValue(c.HealthCheckInterval, false)
return debugMap
}
// ConnPoolConfigWithOptions configures an existing ConnPoolConfig with the passed in options set
func ConnPoolConfigWithOptions(c *ConnPoolConfig, opts ...ConnPoolConfigOption) *ConnPoolConfig {
for _, o := range opts {
o(c)
}
return c
}
// WithOptions configures the receiver ConnPoolConfig with the passed in options set
func (c *ConnPoolConfig) WithOptions(opts ...ConnPoolConfigOption) *ConnPoolConfig {
for _, o := range opts {
o(c)
}
return c
}
// WithMaxIdleTime returns an option that can set MaxIdleTime on a ConnPoolConfig
func WithMaxIdleTime(maxIdleTime time.Duration) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.MaxIdleTime = maxIdleTime
}
}
// WithMaxLifetime returns an option that can set MaxLifetime on a ConnPoolConfig
func WithMaxLifetime(maxLifetime time.Duration) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.MaxLifetime = maxLifetime
}
}
// WithMaxLifetimeJitter returns an option that can set MaxLifetimeJitter on a ConnPoolConfig
func WithMaxLifetimeJitter(maxLifetimeJitter time.Duration) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.MaxLifetimeJitter = maxLifetimeJitter
}
}
// WithMaxOpenConns returns an option that can set MaxOpenConns on a ConnPoolConfig
func WithMaxOpenConns(maxOpenConns int) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.MaxOpenConns = maxOpenConns
}
}
// WithMinOpenConns returns an option that can set MinOpenConns on a ConnPoolConfig
func WithMinOpenConns(minOpenConns int) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.MinOpenConns = minOpenConns
}
}
// WithHealthCheckInterval returns an option that can set HealthCheckInterval on a ConnPoolConfig
func WithHealthCheckInterval(healthCheckInterval time.Duration) ConnPoolConfigOption {
return func(c *ConnPoolConfig) {
c.HealthCheckInterval = healthCheckInterval
}
}