casbin-net / efcore-adapter

Entity Framework Core Adapter for Casbin.NET
https://github.com/casbin/Casbin.NET
Apache License 2.0
48 stars 21 forks source link

Enforcer instances in different processes, different regions #49

Closed johnmillard-ra closed 3 years ago

johnmillard-ra commented 3 years ago

Hello!

Once again, I apologize if there's information I overlooked, or if this is the wrong place to ask this question. As I understand things, Cosmos handles replication across regions, so any policies added or removed in one region will replicate to all other regions (assuming that's what we want and assuming we've configured things correctly).

Is there anything inherent in this adapter that facilitates this behavior? i.e. If I write a policy in Europe, Cosmos will replicate that policy to the US, Asia, etc. - does this adapter ensure that calls to Enforce() hit Cosmos if caching is disabled, absent a preceding call to LoadPolicy()?

Or do I need to watch for changes to the database/container separately, triggering calls to LoadPolicyAsync() in response?

Thanks for your patience! John

hsluoyz commented 3 years ago

@Sagilio

sagilio commented 3 years ago

EFCore Adapter does not have any special behavior for Cosmos DB in the current version, so you may need to call LoadPolicy or LoadPolicyAsync when watched the changes. You can use IWatcher to keep the same policy between instances. It will call Update() or UpdateAsync() method when you call the Add/Remove/Update policy APIs.

johnmillard-ra commented 3 years ago

Excellent - thank you!