Effector
Effect is the result of a policy rule. And the Effector is the interface for Casbin effectors.
MergeEffects()
MergeEffects merges all matching results collected by the enforcer into a single decision.
For example:
Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)
In this example:
Effectis the final decision being merged by this function(Initialized asIndeterminate).explainIndexis the index ofeftwhich isAlloworDeny.(Initialized as-1)erris used to check if the effect is supported.expris the policy effects stored asstringeffectsis the array of the Effect which can beAllow,IndeterminateorDenymatchesis the array showing that if the result is matching the policy.policyIndexis the index of policy in the model.policyLengthis the length of the policy.
The code above illustrates how can we pass the parameters to the MergeEffects function and the function will process the effects and matches based on the expr
To deploy an Effector, we can do this:
var e Effector
Effect, explainIndex, err = e.MergeEffects(expr, effects, matches, policyIndex, policyLength)
The basic idea of the MergeEffects indicates that if the expr can match the results which means that the p_eft is allow, then we can merge all effects at last. And if there are no deny rules are matched, then we allow.
note
If the expr can not match "priority(p_eft) || deny" and also the policyIndex is shorter than policyLength-1, it will short-circuit some effects in the middle.