Documentation ¶
Index ¶
- func ArrayEqual(s1, s2 []string) bool
- func DefaultCallback(string)
- func NewPublishWatcher(addr string, option WatcherOptions) (persist.Watcher, error)
- func NewWatcher(addr string, option WatcherOptions) (persist.Watcher, error)
- type CallbackFunc
- type MSG
- type Watcher
- func (w *Watcher) Close()
- func (w *Watcher) GetWatcherOptions() WatcherOptions
- func (w *Watcher) SetUpdateCallback(callback func(string)) error
- func (w *Watcher) Update() error
- func (w *Watcher) UpdateForAddPolicy(sec, ptype string, params ...string) error
- func (w *Watcher) UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error
- func (w *Watcher) UpdateForRemovePolicy(sec, ptype string, params ...string) error
- func (w *Watcher) UpdateForSavePolicy(model model.Model) error
- type WatcherOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayEqual ¶
func DefaultCallback ¶
func DefaultCallback(string)
func NewPublishWatcher ¶
func NewPublishWatcher(addr string, option WatcherOptions) (persist.Watcher, error)
NewPublishWatcher return a Watcher only publish but not subscribe
func NewWatcher ¶
func NewWatcher(addr string, option WatcherOptions) (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",WatcherOptions{})
Types ¶
type CallbackFunc ¶
type CallbackFunc func(msg string, update, updateForAddPolicy, updateForRemovePolicy, updateForRemoveFilteredPolicy, updateForSavePolicy func(string, interface{}))
func CustomDefaultFunc ¶
func CustomDefaultFunc(defaultFunc func(string, interface{})) CallbackFunc
type MSG ¶
func (*MSG) MarshalBinary ¶
func (*MSG) UnmarshalBinary ¶
UnmarshalBinary decodes the struct into a User
type Watcher ¶
type Watcher struct {
// contains filtered or unexported fields
}
func (*Watcher) GetWatcherOptions ¶
func (w *Watcher) GetWatcherOptions() WatcherOptions
func (*Watcher) SetUpdateCallback ¶
SetUpdateCallback SetUpdateCallBack sets the update callback function invoked by the watcher when the policy is updated. Defaults to Enforcer.LoadPolicy()
func (*Watcher) Update ¶
Update publishes a message to all other casbin instances telling them to invoke their update callback
func (*Watcher) UpdateForAddPolicy ¶
UpdateForAddPolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.AddPolicy()
func (*Watcher) UpdateForRemoveFilteredPolicy ¶
func (w *Watcher) UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error
UpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemoveFilteredNamedGroupingPolicy()
func (*Watcher) UpdateForRemovePolicy ¶
UpdateForRemovePolicy UPdateForRemovePolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemovePolicy()