-
Notifications
You must be signed in to change notification settings - Fork 245
/
zz_generated.cacheconfig.options.go
102 lines (89 loc) · 2.84 KB
/
zz_generated.cacheconfig.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
// Code generated by github.com/ecordell/optgen. DO NOT EDIT.
package server
import (
defaults "github.com/creasty/defaults"
helpers "github.com/ecordell/optgen/helpers"
)
type CacheConfigOption func(c *CacheConfig)
// NewCacheConfigWithOptions creates a new CacheConfig with the passed in options set
func NewCacheConfigWithOptions(opts ...CacheConfigOption) *CacheConfig {
c := &CacheConfig{}
for _, o := range opts {
o(c)
}
return c
}
// NewCacheConfigWithOptionsAndDefaults creates a new CacheConfig with the passed in options set starting from the defaults
func NewCacheConfigWithOptionsAndDefaults(opts ...CacheConfigOption) *CacheConfig {
c := &CacheConfig{}
defaults.MustSet(c)
for _, o := range opts {
o(c)
}
return c
}
// ToOption returns a new CacheConfigOption that sets the values from the passed in CacheConfig
func (c *CacheConfig) ToOption() CacheConfigOption {
return func(to *CacheConfig) {
to.Name = c.Name
to.MaxCost = c.MaxCost
to.NumCounters = c.NumCounters
to.Metrics = c.Metrics
to.Enabled = c.Enabled
to.defaultTTL = c.defaultTTL
}
}
// DebugMap returns a map form of CacheConfig for debugging
func (c CacheConfig) DebugMap() map[string]any {
debugMap := map[string]any{}
debugMap["Name"] = helpers.DebugValue(c.Name, false)
debugMap["MaxCost"] = helpers.DebugValue(c.MaxCost, false)
debugMap["NumCounters"] = helpers.DebugValue(c.NumCounters, false)
debugMap["Metrics"] = helpers.DebugValue(c.Metrics, false)
debugMap["Enabled"] = helpers.DebugValue(c.Enabled, false)
return debugMap
}
// CacheConfigWithOptions configures an existing CacheConfig with the passed in options set
func CacheConfigWithOptions(c *CacheConfig, opts ...CacheConfigOption) *CacheConfig {
for _, o := range opts {
o(c)
}
return c
}
// WithOptions configures the receiver CacheConfig with the passed in options set
func (c *CacheConfig) WithOptions(opts ...CacheConfigOption) *CacheConfig {
for _, o := range opts {
o(c)
}
return c
}
// WithName returns an option that can set Name on a CacheConfig
func WithName(name string) CacheConfigOption {
return func(c *CacheConfig) {
c.Name = name
}
}
// WithMaxCost returns an option that can set MaxCost on a CacheConfig
func WithMaxCost(maxCost string) CacheConfigOption {
return func(c *CacheConfig) {
c.MaxCost = maxCost
}
}
// WithNumCounters returns an option that can set NumCounters on a CacheConfig
func WithNumCounters(numCounters int64) CacheConfigOption {
return func(c *CacheConfig) {
c.NumCounters = numCounters
}
}
// WithMetrics returns an option that can set Metrics on a CacheConfig
func WithMetrics(metrics bool) CacheConfigOption {
return func(c *CacheConfig) {
c.Metrics = metrics
}
}
// WithEnabled returns an option that can set Enabled on a CacheConfig
func WithEnabled(enabled bool) CacheConfigOption {
return func(c *CacheConfig) {
c.Enabled = enabled
}
}