forked from googollee/go-socket.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter_options.go
57 lines (46 loc) · 1003 Bytes
/
adapter_options.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
package socketio
import "fmt"
// RedisAdapterOptions is configuration to create new adapter
type RedisAdapterOptions struct {
// deprecated. Usage Addr options
Host string
// deprecated. Usage Addr options
Port string
Addr string
Prefix string
Network string
}
func (ro *RedisAdapterOptions) getAddr() string {
if ro.Addr == "" {
ro.Addr = fmt.Sprintf("%s:%s", ro.Host, ro.Port)
}
return ro.Addr
}
func defaultOptions() *RedisAdapterOptions {
return &RedisAdapterOptions{
Addr: "127.0.0.1:6379",
Prefix: "socket.io",
Network: "tcp",
}
}
func getOptions(opts *RedisAdapterOptions) *RedisAdapterOptions {
options := defaultOptions()
if opts != nil {
if opts.Host != "" {
options.Host = opts.Host
}
if opts.Port != "" {
options.Port = opts.Port
}
if opts.Addr != "" {
options.Addr = opts.Addr
}
if opts.Prefix != "" {
options.Prefix = opts.Prefix
}
if opts.Network != "" {
options.Network = opts.Network
}
}
return options
}