Categorygithub.com/lucidhq/casbin-redis-watcher/v2
modulepackage
2.0.4
Repository: https://github.com/lucidhq/casbin-redis-watcher.git
Documentation: pkg.go.dev

# README

Redis Watcher Build Status

Redis Watcher is a Redis watcher for Casbin.

Installation

go get github.com/billcobbler/casbin-redis-watcher

Simple Example

package main

import (
    "github.com/casbin/casbin"
    "github.com/casbin/casbin/util"
    "github.com/billcobbler/casbin-redis-watcher"
)

func updateCallback(msg string) {
    util.LogPrint(msg)
}

func main() {
    // Initialize the watcher.
    // Use the Redis host as parameter.
    w, _ := rediswatcher.NewWatcher("127.0.0.1:6379")
    
    // Initialize the enforcer.
    e := casbin.NewEnforcer("examples/rbac_model.conf", "examples/rbac_policy.csv")
    
    // Set the watcher for the enforcer.
    e.SetWatcher(w)
    
    // Set callback to local example
    w.SetUpdateCallback(updateCallback)
    
    // Update the policy to test the effect.
    // You should see "[casbin rules updated]" in the log.
    e.SavePolicy()
}

Getting Help

License

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

# Functions

No description provided by the author
No description provided by the author
IsCallbackPending.
No description provided by the author
NewPublishWatcher return a Watcher only publish but not subscribe.
NewWatcher creates a new Watcher to be used with a Casbin enforcer addr is a redis target string in the format "host:port" setters allows for inline WatcherOptions Example: w, err := rediswatcher.NewWatcher("127.0.0.1:6379", rediswatcher.Password("pass"), rediswatcher.Channel("/yourchan")) A custom redis.Conn can be provided to NewWatcher Example: c, err := redis.Dial("tcp", ":6379") w, err := rediswatcher.NewWatcher("", rediswatcher.WithRedisConnection(c) .
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author