Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Quick return of merging effects #140

Merged
merged 1 commit into from Mar 12, 2021
Merged

Conversation

sagilio
Copy link
Member

@sagilio sagilio commented Mar 7, 2021

Fixes: #139

@sagilio sagilio requested a review from xcaptain March 7, 2021 16:57
@sagilio sagilio self-assigned this Mar 7, 2021
@sagilio sagilio linked an issue Mar 7, 2021 that may be closed by this pull request
@hsluoyz
Copy link
Member

hsluoyz commented Mar 9, 2021

@sagilio plz resolve conflicts:

image

Signed-off-by: Sagilio <Sagilio@outlook.com>
@hsluoyz
Copy link
Member

hsluoyz commented Mar 11, 2021

@xcaptain plz review.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 11, 2021

@sagilio can we release more frequently? the latest release is 26 days ago: https://github.com/casbin/Casbin.NET/releases/tag/v1.5.0

Copy link

@xcaptain xcaptain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I don't understand now, It should be right, we can merge it first and learn the new algorithm gradually.

@@ -631,12 +535,16 @@ private bool Enforce(IReadOnlyList<object> requestValues, ICollection<IEnumerabl
IReadOnlyList<string> policyValues = Enumerable.Repeat(string.Empty, policyTokenCount).ToArray();
ExpressionHandler.SetPolicyParameters(policyValues);
var nowEffect = GetEffect(ExpressionHandler.Invoke(expressionString, requestValues));
finalResult = Effector.MergeEffects(effect, new[] { nowEffect }, null, out hitPolicyIndex);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I do not quite understand this pr, the old behavior is put all policy evaluate result into an effects array and then decide the final result in MergeEffects, you skiped this MergeEffects how can you have a whole view of all the policy effects.

if (explain && hitPolicyIndex is not -1)
{
explains.Add(policyList[hitPolicyIndex]);
if (effector.TryChain(nowEffect))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use TryChain to replace MergeEffects? I do not quite understand this method, but it should be right because all the tests passed.

@hsluoyz hsluoyz merged commit b633663 into casbin:develop Mar 12, 2021
@sagilio
Copy link
Member Author

sagilio commented Mar 15, 2021

@sagilio can we release more frequently? the latest release is 26 days ago: https://github.com/casbin/Casbin.NET/releases/tag/v1.5.0

Ok, Several features rest in the v2.x plan will be implemented in the 1.x version first.

@hsluoyz
Copy link
Member

hsluoyz commented Mar 15, 2021

Is this a breaking change? If not, please put it into origin:master instead of origin:develop. Putting everything into origin:develop like this will cause a big disaster when people start to migrate to it, as they will find so many things have changed, and a cetain number of them may be bugs.

@sagilio sagilio added breaking change This issue will incude some breaking changes enhancement Enhancement the exist feature labels Mar 15, 2021
@sagilio
Copy link
Member Author

sagilio commented Mar 15, 2021

@hsluoyz
This is a breaking change. But now the version can use the IChainEffector to get the same experience. This PR is using the IChainEffector to replace the IEffector. Because the golang casbin (beta) has changed the Effector interface too.
Now, almost all breaking changes in #101 have been merged in the develop branch. It will not have more breaking changes.
I have been trying to reduce the cost of migration as much as possible. Although the structure has changed a lot, the user experience will not be very different now, and these breaking changes can make future updates much more stable.

@github-actions
Copy link

🎉 This PR is included in version 2.0.0-preview.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change This issue will incude some breaking changes enhancement Enhancement the exist feature released on @preview released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Quick return of merging effects
3 participants