MCPcopy
hub / github.com/apache/casbin / updatePolicyCtx

Method updatePolicyCtx

enforcer_context.go:689–706  ·  view source on GitHub ↗
(ctx context.Context, sec string, ptype string, oldRule []string, newRule []string)

Source from the content-addressed store, hash-verified

687}
688
689func (e *ContextEnforcer) updatePolicyCtx(ctx context.Context, sec string, ptype string, oldRule []string, newRule []string) (bool, error) {
690 ok, err := e.updatePolicyWithoutNotifyCtx(ctx, sec, ptype, oldRule, newRule)
691 if !ok || err != nil {
692 return ok, err
693 }
694
695 if e.shouldNotify() {
696 var err error
697 if watcher, ok := e.watcher.(persist.UpdatableWatcher); ok {
698 err = watcher.UpdateForUpdatePolicy(sec, ptype, oldRule, newRule)
699 } else {
700 err = e.watcher.Update()
701 }
702 return true, err
703 }
704
705 return true, nil
706}
707
708func (e *ContextEnforcer) updatePoliciesCtx(ctx context.Context, sec string, ptype string, oldRules [][]string, newRules [][]string) (bool, error) {
709 ok, err := e.updatePoliciesWithoutNotifyCtx(ctx, sec, ptype, oldRules, newRules)

Callers 2

UpdateNamedPolicyCtxMethod · 0.95

Calls 4

shouldNotifyMethod · 0.80
UpdateForUpdatePolicyMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected