Closed bk138 closed 2 years ago
@smrpn @hackerchai @PsiACE @GopherJ
@hackerchai
I've got a question about casbin-rs usage: I'm using it with actix-web and the example states that the Enforcer should be wrapped in an RwLock. I wonder if this is because of the example using FileAdapter and that the protection by the RwLock can maybe be omitted when using a DB adapter like sqlx-adapter? Or does the RwLock protect state inside the single Enforcer instance? Thanks!
We use RwLock because actix-web is actually multi-threads when handling concurrent requests. In this way, you can use adapter to work with cash in.
We use RwLock because actix-web is actually multi-threads when handling concurrent requests. In this way, you can use adapter to work with cash in.
Yep, the question is more like: is Enforcer thread-safe (maybe only with certain adapters)? https://github.com/casbin/casbin-rs/commit/529554e0a044b20bbbc9607e59a5d053b537b86a kinda hints at that. If it is not, it's maybe a good idea to state that in the docs. Would you accept a PR to the README adding a hint?
We use RwLock because actix-web is actually multi-threads when handling concurrent requests. In this way, you can use adapter to work with cash in.
Yep, the question is more like: is Enforcer thread-safe (maybe only with certain adapters)? 529554e kinda hints at that. If it is not, it's maybe a good idea to state that in the docs. Would you accept a PR to the README adding a hint?
The enforcer is not thread-safe. PR is always welcomed.
From my experience, sqlx adapter will update the DB, but not the enforcer's model, so that any changes will not have any effect.
I've got a question about casbin-rs usage: I'm using it with actix-web and the example states that the Enforcer should be wrapped in an RwLock. I wonder if this is because of the example using FileAdapter and that the protection by the RwLock can maybe be omitted when using a DB adapter like sqlx-adapter? Or does the RwLock protect state inside the single Enforcer instance? Thanks!