Documentation ¶
Index ¶
- func NewPublishWatcher(addr string, setters ...WatcherOption) (persist.Watcher, error)
- func NewWatcher(addr string, setters ...WatcherOption) (persist.Watcher, error)
- type Watcher
- type WatcherOption
- func Channel(subject string) WatcherOption
- func IgnoreSelf(ignore bool) WatcherOption
- func LocalID(id string) WatcherOption
- func Password(password string) WatcherOption
- func Protocol(protocol string) WatcherOption
- func SquashMessages(squash bool) WatcherOption
- func SquashTimeoutLong(d time.Duration) WatcherOption
- func SquashTimeoutShort(d time.Duration) WatcherOption
- func WithRedisPubConnection(connection redis.Conn) WatcherOption
- func WithRedisSubConnection(connection redis.Conn) WatcherOption
- type WatcherOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPublishWatcher ¶
func NewPublishWatcher(addr string, setters ...WatcherOption) (persist.Watcher, error)
NewPublishWatcher return a Watcher only publish but not subscribe
func NewWatcher ¶
func NewWatcher(addr string, setters ...WatcherOption) (persist.Watcher, error)
NewWatcher creates a new Watcher to be used with a Casbin enforcer addr is a redis target string in the format "host:port" setters allows for inline WatcherOptions
Example: w, err := rediswatcher.NewWatcher("127.0.0.1:6379", rediswatcher.Password("pass"), rediswatcher.Channel("/yourchan"))
A custom redis.Conn can be provided to NewWatcher
Example: c, err := redis.Dial("tcp", ":6379") w, err := rediswatcher.NewWatcher("", rediswatcher.WithRedisConnection(c)
Types ¶
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func (*Watcher) GetWatcherOptions ¶
func (w *Watcher) GetWatcherOptions() WatcherOptions
return option settings
func (*Watcher) SetUpdateCallback ¶
SetUpdateCallBack sets the update callback function invoked by the watcher when the policy is updated. Defaults to Enforcer.LoadPolicy()
type WatcherOption ¶
type WatcherOption func(*WatcherOptions)
func Channel ¶
func Channel(subject string) WatcherOption
func IgnoreSelf ¶
func IgnoreSelf(ignore bool) WatcherOption
func LocalID ¶
func LocalID(id string) WatcherOption
func Password ¶
func Password(password string) WatcherOption
func Protocol ¶
func Protocol(protocol string) WatcherOption
func SquashMessages ¶
func SquashMessages(squash bool) WatcherOption
func SquashTimeoutLong ¶
func SquashTimeoutLong(d time.Duration) WatcherOption
func SquashTimeoutShort ¶
func SquashTimeoutShort(d time.Duration) WatcherOption
func WithRedisPubConnection ¶
func WithRedisPubConnection(connection redis.Conn) WatcherOption
func WithRedisSubConnection ¶
func WithRedisSubConnection(connection redis.Conn) WatcherOption
Click to show internal directories.
Click to hide internal directories.