-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
58 lines (48 loc) · 938 Bytes
/
config.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
package gomq
import (
"sync"
"time"
)
type Config struct {
sync.RWMutex
reconnectTimeout time.Duration
connectTimeout time.Duration
queueLen int
}
func (c *Config) Default() {
c.Lock()
defer c.Unlock()
c.reconnectTimeout = time.Second
c.connectTimeout = time.Second * 3
c.queueLen = 1024
}
func (c *Config) ReconnectTimeout() time.Duration {
c.RLock()
defer c.RUnlock()
return c.reconnectTimeout
}
func (c *Config) SetReconnectTimeout(d time.Duration) {
c.Lock()
defer c.Unlock()
c.reconnectTimeout = d
}
func (c *Config) ConnectTimeout() time.Duration {
c.RLock()
defer c.RUnlock()
return c.connectTimeout
}
func (c *Config) SetConnectTimeout(d time.Duration) {
c.Lock()
defer c.Unlock()
c.connectTimeout = d
}
func (c *Config) QueueLen() int {
c.RLock()
defer c.RUnlock()
return c.queueLen
}
func (c *Config) SetQueueLen(queueLen int) {
c.Lock()
defer c.Unlock()
c.queueLen = queueLen
}