Passer au contenu principal

Observateurs

We support the use of distributed messaging systems like etcd to maintain consistency between multiple Casbin enforcer instances. This allows our users to concurrently use multiple Casbin enforcers to handle a large number of permission checking requests.

Similar to policy storage adapters, we do not include watcher code in the main library. Tout support pour un nouveau système de messagerie devrait être mis en œuvre en tant que observateur. A complete list of Casbin watchers is provided below. We welcome any third-party contributions for a new watcher, please inform us and we will add it to this list:)

ObservateurType de texteAuteurDescription
PostgreSQL WatcherExDatabase@IguteChungWatcherEx for PostgreSQL
Redis WatcherExMagasin KVCasbinWatcherEx for Redis
Guetteur RedisMagasin KV@billcobblerObservateur pour Redis
Observateur EtcdMagasin KVCasbinObservateur pour etcd
Guetteur TiKVMagasin KVCasbinObservateur pour TiKV
Guet de KafkaSystème de messagerie@wgarunapObservateur pour Apache Kafka
Observateur NATSSystème de messagerieSolutionObservateur pour NATS
Guetteur ZooKeeperSystème de messagerieGrepsrObservateur pour Apache ZooKeeper
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemorySystème de messagerie@rusenaskWatcher basé sur Go Cloud Dev Kit qui fonctionne avec les principaux fournisseurs de cloud et les infrastructures auto-hébergées
NATS, RabbitMQ, GCP Pub/Sub, AWS SNS & SQS, Kafka, InMemoryMessaging System@bartventerWatcherEx based on Go Cloud Dev Kit that works with leading cloud providers and self-hosted infrastructure
Observateur de RocketMQSystème de messagerie@fmyxyzObservateur pour Apache RocketMQ

format@@0 WatcherEx

Afin de prendre en charge la synchronisation incrémentale entre plusieurs instances, nous fournissons l'interface WatcherEx. Nous espérons qu'il pourra notifier d'autres instances lorsque la politique changera, mais il n'y a actuellement aucune implémentation de WatcherEx. Nous vous recommandons d'utiliser le répartiteur pour y parvenir.

Comparé à l'interface Watcher , WatcherEx peut distinguer quel type d'action de mise à jour est reçu, e. ., AddPolicy et RemovePolicy.

Application WatcherEx :

APIDescription
SetUpdateCallback(func(string)) errorSetUpdateCallback sets the callback function that the watcher will call, when the policy in DB has been changed by other instances. Un callback classique est Enforcer.LoadPolicy().
Update() errorUpdate calls the update callback of other instances to synchronize their policy. Il est généralement appelé après avoir changé la politique dans DB, comme 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) errorUpdateForAddPolicy calls the update callback of other instances to synchronize their policy. Il est appelé après qu'une politique est ajoutée via Enforcer.AddPolicy(), Enforcer.AddNamedPolicy(), Enforcer.AddGroupingPolicy() et Enforcer.AddNamedGroupingPolicy().
UpdateForRemovePolicy(sec, ptype string, params ...string) errorUPdateForRemovePolicy calls the update callback of other instances to synchronize their policy. Il est appelé après qu'une politique est supprimée par Enforcer.RemovePolicy(), Enforcer.RemoveNamedPolicy(), Enforcer.RemoveGroupingPolicy() et Enforcer.RemoveNamedGroupingPolicy().
UpdateForRemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) errorUpdateForRemoveFilteredPolicy calls the update callback of other instances to synchronize their policy. Il est appelé après Enforcer.RemoveFilteredPolicy(), Enforcer.RemoveFilteredNamedPolicy(), Enforcer.RemoveFilteredGroupingPolicy() et Enforcer.RemoveFilteredNamedNamedPolicy().
UpdateForSavePolicy(model model.Model) errorUpdateForSavePolicy calls the update callback of other instances to synchronize their policy. Il est appelé après Enforcer.SavePolicy()
UpdateForAddPolicies(sec string, ptype string, rules ...[]string) errorUpdateForAddPolicies calls the update callback of other instances to synchronize their policy. Il est appelé après Enforcer.AddPolicies(), Enforcer.AddNamedPolicies(), Enforcer.AddGroupingPolicies() et Enforcer.AddNamedGroupingPolicies().
UpdateForRemovePolicies(sec string, ptype string, rules ...[]string) errorUpdateForRemovePolicies calls the update callback of other instances to synchronize their policy. Il est appelé après Enforcer.RemovePolicies(), Enforcer.RemoveNamedPolicies(), Enforcer.RemoveGroupingPolicies() et Enforcer.RemoveNamedGroupingPolicies().