forked from weixinhost/yar.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opt.go
50 lines (45 loc) · 1.13 KB
/
opt.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
package yar
type YarOpt int
const (
//YarOptMagicNumber 代表协议中规定的相关信息,用于进行请求验证使用
YarOptMagicNumber YarOpt = 1
//YarOptTimeout 处理超时
YarOptTimeout = 2
//YarOptConnectTimeout 连接超时,只有在非http类server中有意义
YarOptConnectTimeout = 3
//YarOptPackager 数据打包协议,目前只支持json
YarOptPackager = 4
//YarOptEncrypt 是否启用加密
YarOptEncrypt = 5
//YarOptEncryptPrivateKey 用于加密的aes key
YarOptEncryptPrivateKey = 6
)
const (
LogLevelDebug int = 0x0001
LoglevelNormal int = 0x0002
LogLevelError int = 0x0004
)
type Opt struct {
MagicNumber uint32
Timeout uint32
ConnectTimeout uint32
Packager string
Encrypt bool
EncryptPrivateKey string
DynamicParam bool
DNSCache bool
LogLevel int
}
func NewOpt() *Opt {
opt := new(Opt)
opt.MagicNumber = MagicNumber
opt.Encrypt = false
opt.EncryptPrivateKey = ""
opt.Packager = "json"
opt.ConnectTimeout = 1000 * 5
opt.Timeout = 30 * 1000
opt.DynamicParam = false
opt.DNSCache = true
opt.LogLevel = LogLevelError
return opt
}