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.
()
| 151 | // It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), |
| 152 | // Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc. |
| 153 | func (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. |
| 164 | func (w *Watcher) startWatch() error { |