代码拉取完成,页面将自动刷新
package rediswatcher
import (
"time"
"github.com/go-redis/redis/v8"
)
type WatcherOptions struct {
Channel string
PubConn *redis.Client
SubConn *redis.Client
Username string
Password string
Protocol string
IgnoreSelf bool
LocalID string
RecordMetrics func(*WatcherMetrics)
SquashMessages bool
SquashTimeoutShort time.Duration
SquashTimeoutLong time.Duration
callbackPending bool
}
type WatcherOption func(*WatcherOptions)
func Channel(subject string) WatcherOption {
return func(options *WatcherOptions) {
options.Channel = subject
}
}
func Username(username string) WatcherOption {
return func(options *WatcherOptions) {
options.Username = username
}
}
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
}
}
func LocalID(id string) WatcherOption {
return func(options *WatcherOptions) {
options.LocalID = id
}
}
func IgnoreSelf(ignore bool) WatcherOption {
return func(options *WatcherOptions) {
options.IgnoreSelf = ignore
}
}
func SquashMessages(squash bool) WatcherOption {
return func(options *WatcherOptions) {
options.SquashMessages = squash
}
}
func RecordMetrics(callback func(*WatcherMetrics)) WatcherOption {
return func(options *WatcherOptions) {
options.RecordMetrics = callback
}
}
func SquashTimeoutShort(d time.Duration) WatcherOption {
return func(options *WatcherOptions) {
options.SquashTimeoutShort = d
}
}
func SquashTimeoutLong(d time.Duration) WatcherOption {
return func(options *WatcherOptions) {
options.SquashTimeoutLong = d
}
}
// IsCallbackPending
func IsCallbackPending(w *Watcher, shouldClear bool) bool {
r := w.options.callbackPending
if shouldClear {
w.options.callbackPending = false
}
return r
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。