MCPcopy Create free account
hub / github.com/apache/casbin-etcd-watcher / SetUpdateCallback

Method SetUpdateCallback

watcher.go:143–148  ·  view source on GitHub ↗

SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances. A classic callback is Enforcer.LoadPolicy().

(callback func(string))

Source from the content-addressed store, hash-verified

141// when the policy in DB has been changed by other instances.
142// A classic callback is Enforcer.LoadPolicy().
143func (w *Watcher) SetUpdateCallback(callback func(string)) error {
144 w.lock.Lock()
145 defer w.lock.Unlock()
146 w.callback = callback
147 return nil
148}
149
150// Update calls the update callback of other instances to synchronize their policy.
151// It is usually called after changing the policy in DB, like Enforcer.SavePolicy(),

Callers 2

TestWatcherFunction · 0.95
TestWithEnforcerFunction · 0.95

Calls

no outgoing calls

Tested by 2

TestWatcherFunction · 0.76
TestWithEnforcerFunction · 0.76