-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
41 lines (34 loc) · 910 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
package link
import "time"
type mode int
const (
ClientMode mode = iota
ServerMode
defaultReadBufSize = 64 * 1024 // can buf data size
// defaultWriteBufSize = 64 * 1024
)
// Config manager config.
type Config struct {
AcceptQueueSize int
KeepaliveInterval time.Duration // if config mode is ServerMode, KeepaliveInterval will be ignored
BufferSize int
DebugLog bool // enable debug log
Mode mode // manager run mode
ReadBufSize int32
}
// DefaultConfig default config.
func DefaultConfig(mode mode) Config {
return Config{
AcceptQueueSize: 1000,
BufferSize: 65535,
DebugLog: false,
Mode: mode,
ReadBufSize: defaultReadBufSize,
}
}
// KeepaliveConfig DefaultConfig enable keepalive.
func KeepaliveConfig(mode mode) Config {
config := DefaultConfig(mode)
config.KeepaliveInterval = 15 * time.Second
return config
}