-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
49 lines (40 loc) · 784 Bytes
/
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
package idgenerator
type LifeCycleType int
const (
Second LifeCycleType = iota
Minute
Hour
)
type Config struct {
Instance string
Prefix string
GroupLength int
SequenceFormat string
LifeCycle LifeCycleType
}
type Option func(*Config)
func Instance(instance string) Option {
return func(c *Config) {
c.Instance = instance
}
}
func Prefix(prefix string) Option {
return func(c *Config) {
c.Prefix = prefix
}
}
func GroupLength(groupLength int) Option {
return func(c *Config) {
c.GroupLength = groupLength
}
}
func SequenceFormat(sequenceFormat string) Option {
return func(c *Config) {
c.SequenceFormat = sequenceFormat
}
}
func LifeCycle(lifeCycle LifeCycleType) Option {
return func(c *Config) {
c.LifeCycle = lifeCycle
}
}