-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
96 lines (79 loc) · 1.33 KB
/
types.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
package red
import (
"errors"
"time"
)
func NewOptionDuration (duration time.Duration) OptionDuration {
return OptionDuration{
Valid: true,
Duration: duration,
}
}
type OptionDuration struct {
Valid bool
Duration time.Duration
}
func NewOptionInt64 (i int64) OptionInt64 {
return OptionInt64{
Valid: true,
Int64: i,
}
}
type OptionInt64 struct {
Valid bool
Int64 int64
}
func NewOptionUint8(i uint8) OptionUint8 {
return OptionUint8 {
Valid: true,
Uint8: i,
}
}
type OptionUint8 struct {
Valid bool
Uint8 uint8
}
func NewOptionUint32 (i uint32) OptionUint32 {
return OptionUint32{
Valid: true,
Uint32: i,
}
}
type OptionUint32 struct {
Valid bool
Uint32 uint32
}
func NewOptionUint64 (i uint64) OptionUint64 {
return OptionUint64{
Valid: true,
Uint64: i,
}
}
type OptionUint64 struct {
Valid bool
Uint64 uint64
}
func NewOptionString(s string) OptionString {
return OptionString{
Valid: true,
String: s,
}
}
type OptionString struct {
Valid bool
String string
}
type KeyValue struct {
Key string
Value string
}
type Retry struct {
Times uint8
Interval time.Duration
}
func (data Retry) check() error {
if data.Times > 0 && data.Interval == 0 {
return errors.New("goclub/redis(ERR_MISSING_RETRY_DURATION) if Retry{}.Times > 0 then Retry{}.Interval can not be zero")
}
return nil
}