Watchers
我们支持使用分布式消息系统,如etcd,来维持多个Casbin执行器实例之间的一致性。 这使我们的用户能够并发使用多个Casbin执行器来处理大量的权限检查请求。
与策略存储适配器类似,我们并未在主库中包含观察者代码。 对新的消息系统的任何支持都应作为观察者来实现。 下面提供了Casbin观察者的完整列表。 我们欢迎任何第三方为新的观察者做出贡献,请通知我们,我们会将其添加到此列表中:
- Go
- Java
- Node.js
- Python
- .NET
- Ruby
- PHP
- Rust
Watcher | Type | Author | Description |
---|---|---|---|
PostgreSQL WatcherEx | Database | @IguteChung | WatcherEx for PostgreSQL |
Redis WatcherEx | KV store | Casbin | WatcherEx for Redis |
Redis Watcher | KV store | @billcobbler | Watcher for Redis |
Etcd Watcher | KV store | Casbin | Watcher for etcd |
TiKV Watcher | KV store | Casbin | Watcher for TiKV |
Kafka Watcher | Messaging system | @wgarunap | Watcher for Apache Kafka |
NATS Watcher | Messaging system | Soluto | Watcher for NATS |
ZooKeeper Watcher | Messaging system | Grepsr | Watcher for Apache ZooKeeper |
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemory | Messaging System | @rusenask | Watcher based on Go Cloud Dev Kit that works with leading cloud providers and self-hosted infrastructure |
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemory | Messaging System | @bartventer | WatcherEx based on Go Cloud Dev Kit that works with leading cloud providers and self-hosted infrastructure |
RocketMQ Watcher | Messaging system | @fmyxyz | Watcher for Apache RocketMQ |
Watcher | Type | Author | Description |
---|---|---|---|
Etcd Adapter | KV store | @mapleafgo | Watcher for etcd |
Redis Watcher | KV store | Casbin | Watcher for Redis |
Redis WatcherEx | KV store | Casbin | WatcherEx for Redis |
Lettuce-Based Redis Watcher | KV store | Casbin | Watcher for Redis based on Lettuce) |
PostgreSQL Watcher | Database | Casbin | Watcher for PostgreSQL |
Kafka Watcher | Messaging system | Casbin | Watcher for Apache Kafka |
ZooKeeper Watcher | Messaging system | Casbin | Watcher for Apache ZooKeeper |
Watcher | Type | Author | Description |
---|---|---|---|
Etcd Watcher | KV store | Casbin | Watcher for etcd |
Redis Watcher | KV store | Casbin | Watcher for Redis |
Pub/Sub Watcher | Messaging system | Casbin | Watcher for Google Cloud Pub/Sub |
MongoDB Change Streams Watcher | Database | Casbin | Watcher for MongoDB Change Streams |
Postgres Watcher | Database | @mcollina | Watcher for PostgreSQL |
Watcher | Type | Author | Description |
---|---|---|---|
Etcd Watcher | KV store | Casbin | Watcher for etcd |
Redis Watcher | KV store | Casbin | Watcher for Redis |
Redis Watcher | KV store | ScienceLogic | Watcher for Redis |
Redis Async Watcher | KV store | @kevinkelin | Watcher for Redis |
PostgreSQL Watcher | Database | Casbin | Watcher for PostgreSQL |
RabbitMQ Watcher | Messaging system | Casbin | Watcher for RabbitMQ |
Watcher | Type | Author | Description |
---|---|---|---|
Redis Watcher | KV store | @Sbou | Watcher for Redis |
Watcher | Type | Author | Description |
---|---|---|---|
Redis Watcher | KV store | CasbinRuby | Watcher for Redis |
RabbitMQ Watcher | Messaging system | CasbinRuby | Watcher for RabbitMQ |
Watcher | Type | Author | Description |
---|---|---|---|
Redis Watcher | KV store | @Tinywan | Watcher for Redis |
Watcher | Type | Author | Description |
---|---|---|---|
Redis Watcher | KV store | Casbin | Watcher for Redis |
WatcherEx
In order to support incremental synchronization between multiple instances, we provide the WatcherEx
interface. We hope it can notify other instances when the policy changes, but there is currently no implementation of WatcherEx
. We recommend that you use dispatcher to achieve this.
Compared with Watcher
interface, WatcherEx
can distinguish what type of update action is received, e.g., AddPolicy
and RemovePolicy
.
WatcherEx Apis:
API | Description |
---|---|
SetUpdateCallback(func(string)) error | SetUpdateCallback sets the callback function that the watcher will call, when the policy in DB has been changed by other instances. A classic callback is Enforcer.LoadPolicy(). |
Update() error | Update calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.SavePolicy(), Enforcer.AddPolicy(), Enforcer.RemovePolicy(), etc. |
Close() | Close stops and releases the watcher, the callback function will not be called any more. |
UpdateForAddPolicy(sec, ptype string, params ...string) error | UpdateForAddPolicy calls the update callback of other instances to synchronize their policy. It is called after a policy is added via Enforcer.AddPolicy(), Enforcer.AddNamedPolicy(), Enforcer.AddGroupingPolicy() and Enforcer.AddNamedGroupingPolicy(). |
UpdateForRemovePolicy(sec, ptype string, params ...string) error | UPdateForRemovePolicy calls the update callback of other instances to synchronize their policy. It is called after a policy is removed by Enforcer.RemovePolicy(), Enforcer.RemoveNamedPolicy(), Enforcer.RemoveGroupingPolicy() and Enforcer.RemoveNamedGroupingPolicy(). |
UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error | UpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemoveFilteredPolicy(), Enforcer.RemoveFilteredNamedPolicy(), Enforcer.RemoveFilteredGroupingPolicy() and Enforcer.RemoveFilteredNamedGroupingPolicy(). |
UpdateForSavePolicy(model model.Model) error | UpdateForSavePolicy calls the update callback of other instances to synchronize their policy. It is called after Enforcer.SavePolicy() |
UpdateForAddPolicies(sec string, ptype string, rules ...[]string) error | UpdateForAddPolicies calls the update callback of other instances to synchronize their policy. It is called after Enforcer.AddPolicies(), Enforcer.AddNamedPolicies(), Enforcer.AddGroupingPolicies() and Enforcer.AddNamedGroupingPolicies(). |
UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) error | UpdateForRemovePolicies calls the update callback of other instances to synchronize their policy. It is called after Enforcer.RemovePolicies(), Enforcer.RemoveNamedPolicies(), Enforcer.RemoveGroupingPolicies() and Enforcer.RemoveNamedGroupingPolicies(). |