Documentation
¶
Index ¶
- Variables
- func Setup(db *gorm.DB, _ string) *casbin.SyncedEnforcer
- func UpdateCallback(msg string)
- type Logger
- func (l *Logger) EnableLog(enable bool)
- func (l *Logger) IsEnabled() bool
- func (l *Logger) LogEnforce(matcher string, request []interface{}, result bool, explains [][]string)
- func (l *Logger) LogModel(model [][]string)
- func (l *Logger) LogPolicy(policy map[string][][]string)
- func (l *Logger) LogRole(roles []string)
Constants ¶
This section is empty.
Variables ¶
var ReloadInterval = time.Minute
ReloadInterval is how often the shared enforcer reloads its policy from the database.
A policy written on one instance reaches the others no other way: the adapter writes to the database, and every other process keeps serving what it loaded at startup. Set this to zero before the first Setup to opt out — a single-instance deployment gains nothing from the query.
Functions ¶
func UpdateCallback ¶
func UpdateCallback(msg string)
UpdateCallback reloads the policy, for use as a watcher's update callback.
Setup polls instead, which needs no broker. A deployment that already has one can register a watcher against this and have the change arrive at once rather than within ReloadInterval:
enforcer.SetWatcher(w) w.SetUpdateCallback(mycasbin.UpdateCallback)
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is the implementation for a Logger using golang log.
func (*Logger) LogEnforce ¶
func (l *Logger) LogEnforce(matcher string, request []interface{}, result bool, explains [][]string)
LogEnforce log info related to enforce.