Awesome Open Source
Awesome Open Source

Etcd Watcher Go Coverage Status Godoc

Etcd Watcher is the Etcd watcher for Casbin. With this library, Casbin can synchronize the policy with the database in multiple enforcer instances.


go get

Simple Example

package main

import (

    casbin ""
    etcdwatcher ""

func updateCallback(rev string) {
    log.Println("New revision detected:", rev)

func main() {
    // Initialize the watcher.
    // Use the endpoint of etcd cluster as parameter.
    w, _ := etcdwatcher.NewWatcher([]string{""}, "keyname")
    // Initialize the enforcer.
    e, _ := casbin.NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv")
    // Set the watcher for the enforcer.
    // By default, the watcher's callback is automatically set to the
    // enforcer's LoadPolicy() in the SetWatcher() call.
    // We can change it by explicitly setting a callback.
    // Update the policy to test the effect.
    // You should see "[New revision detected: X]" in the log.

Getting Help


This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Go (171,982
Database (92,934
Authorization (5,948
Etcd (2,092
Access Control (1,141
Casbin (300