SetUpdateCallback(func(string)) error | SetUpdateCallback sets the callback function that the watcher will call, when the policy in DB has been changed by other instances. 一种典型的回调是Enforcer.LoadPolicy()。 |
Update() error | Update calls the update callback of other instances to synchronize their policy. 它通常是在改变数据库中的策略之后进行的,如Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy()等。 |
Close() | Close stops and releases the watcher, the callback function will not be called any more. |
UpdateForAddPolicy(sec, ptype string, params ...string) error | UpdateForAddPolicy calls the update callback of other instances to synchronize their policy. 它是在 Enforcer.AddPolicy(), Enforcer.AddNamedPolicy(), Enforcer.AddGroupingPolicy() 和 Enforcer.AddNamedGroupingPolicy() 后被调用。 |
UpdateForRemovePolicy(sec, ptype string, params ...string) error | UPdateForRemovePolicy calls the update callback of other instances to synchronize their policy. 它是在政策被Enforcer.RemovePolicy(), Enforcer.RemoveNamedPolicy(), Enforcer.RemoveGroupingPolicy() 和 Enforcer.RemoveNamedGroupingPolicy() 删除后被调用。 |
UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error | UpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy. 它是在Enforcer.RemoveFilteredPolicy(), Enforcer.RemoveFilteredNamedPolicy(), Enforcer.RemoveFilteredGroupingPolicy() 和 Enforcer.RemoveFilteredNamedGroupingPolicy()之后被调用 |
UpdateForSavePolicy(model model.Model) error | UpdateForSavePolicy calls the update callback of other instances to synchronize their policy. 它在 Enforcer.AddPolicy()被调用后调用 |
UpdateForAddPolicies(sec string, ptype string, rules ...[]string) error | UpdateForAddPolicies calls the update callback of other instances to synchronize their policy. 它是在Enforcer.AddPolicies(), Enforcecer.AddNamedPolicies(), Enforcer.AddGroupingPolicies() 和 Enforcer.AddNamedGroupingPolicies()之后被调用 |
UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) error | UpdateForRemovePolicies calls the update callback of other instances to synchronize their policy. 它是在Enforcer.RemovePolicies(), Enforcecer.RemoveNamedPolicies(), Enforcer.RemoveGroupingPolicies() 和 Enforcer.RemoveNamedGroupingPolicies() 后被调用。 |