pycasbin
pycasbin copied to clipboard
Process support
The current use of SyncedEnforcer
can meet the multi-threaded situation, And is it possible for Casbin
to support multi-process use in the future?
I try to modify on the basis of SyncedEnforcer
. (The data mentioned below refers to the data in the memory)
- Modify
_rwlock
, replace the thread read-write lock with the process read-write lock; - Multi-process data synchronization (addition, deletion and modification);
For 1, try to use the Redis module to replace the use of the RWLockWrite internal thread module. For 2, there can be multiple implementation methods:
- Consider rewriting Watcher, and modify the
update
method, internally use the form of message subscription publication for multi-process data synchronization;(No parameters are passed inwatcher.update
in the project) - Use Redis as data storage to achieve data synchronization;
The above ideas were partially implemented and then interrupted. Because of insufficient personal ability, I felt that such implementation would cause the program to be complicated.
So I want to ask whether it will support multi-process use in the future, or Casbin
is for multi-threaded service from the beginning.
@ffyuanda @Zxilly @techoner @elfisworking
@pppigg Watcher is the correct mechanism for multiple Casbin instances' usage. For Redis, you just need to use: https://github.com/ScienceLogic/pycasbin-redis-watcher
Will you consider supporting multiple processes in the future (similar to SyncedEnforcer
), because it also involves operation synchronization.
pycasbin-redis-watcher
can solve the problem of data synchronization.
@pppigg Currently I'm working to bring an official support for PyCasbin Redis Watcher
, it is in progress.
You can also refer to the pycasbin-redis-watcher for now, though its implementation somehow differs from how Go implements the Watcher.
The work has been suspended for quite a while coz I'm busy these days. Will resume the work around this month.
@ffyuanda Very much looking forward to it.
How i can start contribute
@Abingcbc @fabian4
@zhang-wujun we already have the official Redis watcher for PyCasbin, please use it: https://github.com/pycasbin/redis-watcher