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

Method Update

watcher.go:153–161  ·  view source on GitHub ↗

Update calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.

()

Source from the content-addressed store, hash-verified

151// It is usually called after changing the policy in DB, like Enforcer.SavePolicy(),
152// Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc.
153func (w *Watcher) Update() error {
154 w.lock.Lock()
155 defer w.lock.Unlock()
156 resp, err := w.client.Put(context.TODO(), w.keyName, "")
157 if err == nil {
158 w.lastSentRev = resp.Header.GetRevision()
159 }
160 return err
161}
162
163// startWatch is a goroutine that watches the policy change.
164func (w *Watcher) startWatch() error {

Callers 1

TestWatcherFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestWatcherFunction · 0.76