-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
41 lines (35 loc) · 901 Bytes
/
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
package go_socketio_redis_adapter
// Options is configuration to create new adapter.
type Options struct {
Addr string
Prefix string
Network string //notice: redis supported tcp|unix network
}
// newOptions create default options.
func newOptions() *Options {
return &Options{
Addr: "127.0.0.1:6379",
Prefix: "socket.io",
Network: "tcp",
}
}
// OptionsFunc as option interface.
type OptionsFunc func(o *Options)
// WithAddrOptions set custom connect addr.
func WithAddrOptions(addr string) OptionsFunc {
return func(o *Options) {
o.Addr = addr
}
}
// WithPrefixOptions set custom prefix for redis key.
func WithPrefixOptions(prefix string) OptionsFunc {
return func(o *Options) {
o.Prefix = prefix
}
}
// WithNetworkOptions set custom connection network type.
func WithNetworkOptions(network string) OptionsFunc {
return func(o *Options) {
o.Network = network
}
}