forked from olahol/melody
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
58 lines (48 loc) · 1.36 KB
/
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 melody
import "time"
// UseRedisPool - USE REDIS POOL
var UseRedisPool = true
// DebugRedisPoolConn -
var DebugRedisPoolConn = 0
// RedisRcvConn -
var RedisRcvConn = 10
// RedisRcvRetryInterval -
var RedisRcvRetryInterval int = 1
// RedisURL -
var RedisURL = "127.0.0.1:6379"
// Config melody configuration struct.
type Config struct {
WriteWait time.Duration // Milliseconds until write times out.
PongWait time.Duration // Timeout for waiting on pong.
PingPeriod time.Duration // Milliseconds between pings.
MaxMessageSize int64 // Maximum size in bytes of a message.
MessageBufferSize int // The max amount of messages that can be in a sessions buffer before it starts dropping them.
}
func newConfig() *Config {
return &Config{
WriteWait: 60 * time.Second,
PongWait: 60 * time.Second,
PingPeriod: (60 * time.Second * 9) / 10,
MaxMessageSize: 512,
MessageBufferSize: 256,
}
}
// StatsRedis -
type StatsRedis struct {
URL string
MaxIdle int
MaxActive int
ConnectTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
}
func newStatsRedis(url string) *StatsRedis {
return &StatsRedis{
URL: url,
MaxIdle: 5,
MaxActive: 20,
ConnectTimeout: 10 * time.Second,
ReadTimeout: 0,
WriteTimeout: 0,
}
}