-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
45 lines (37 loc) · 894 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
42
43
44
45
package rediswatcher
import (
"github.com/go-redis/redis"
)
type WatcherOptions struct {
Channel string
PubConn *redis.Client
SubConn *redis.Client
Password string
Protocol string
}
type WatcherOption func(*WatcherOptions)
func Channel(subject string) WatcherOption {
return func(options *WatcherOptions) {
options.Channel = subject
}
}
func Password(password string) WatcherOption {
return func(options *WatcherOptions) {
options.Password = password
}
}
func Protocol(protocol string) WatcherOption {
return func(options *WatcherOptions) {
options.Protocol = protocol
}
}
func WithRedisSubConnection(connection *redis.Client) WatcherOption {
return func(options *WatcherOptions) {
options.SubConn = connection
}
}
func WithRedisPubConnection(connection *redis.Client) WatcherOption {
return func(options *WatcherOptions) {
options.PubConn = connection
}
}