Documentation ¶
Index ¶
- Constants
- type Config
- type Enforcer
- type MockAdapter
- func (a *MockAdapter) AddPolicy(sec, ptype string, rule []string) error
- func (a *MockAdapter) LoadPolicy(m model.Model) error
- func (a *MockAdapter) RemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error
- func (a *MockAdapter) RemovePolicy(sec, ptype string, rule []string) error
- func (a *MockAdapter) SavePolicy(m model.Model) error
- type MockWatcher
Constants ¶
View Source
const ( // DefaultModelText 默认 casbin 模型文本 DefaultModelText = `` /* 289-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { ModelText string `json:",optional"` // casbin 模型文本,为空则使用 DefaultModelText RetryDuration time.Duration `json:",default=500ms"` // 加载决策规则重试间隔 RetryMaxTimes int `json:",default=5"` // 加载决策规则重试最大次数 }
Config 决策规则执行器配置
type Enforcer ¶
type Enforcer struct { *casbin.SyncedEnforcer // contains filtered or unexported fields }
Enforcer 决策规则执行器
func MustNewEnforcer ¶
MustNewEnforcer 新建决策规则执行器
func NewEnforcer ¶
NewEnforcer 新建决策规则执行器
type MockAdapter ¶
type MockAdapter struct{}
MockAdapter 模拟决策规则适配器
func (*MockAdapter) AddPolicy ¶
func (a *MockAdapter) AddPolicy(sec, ptype string, rule []string) error
AddPolicy 添加决策规则
func (*MockAdapter) LoadPolicy ¶
func (a *MockAdapter) LoadPolicy(m model.Model) error
LoadPolicy 加载决策规则
func (*MockAdapter) RemoveFilteredPolicy ¶
func (a *MockAdapter) RemoveFilteredPolicy(sec, ptype string, fieldIndex int, fieldValues ...string) error
RemoveFilteredPolicy 移除筛选后的决策规则
func (*MockAdapter) RemovePolicy ¶
func (a *MockAdapter) RemovePolicy(sec, ptype string, rule []string) error
RemovePolicy 移除决策规则
func (*MockAdapter) SavePolicy ¶
func (a *MockAdapter) SavePolicy(m model.Model) error
SavePolicy 保存决策规则
type MockWatcher ¶
type MockWatcher struct {
// contains filtered or unexported fields
}
MockWatcher 模拟决策规则观察器
func (*MockWatcher) SetUpdateCallback ¶
func (w *MockWatcher) SetUpdateCallback(callback func(string)) error
SetUpdateCallback 设置更新回调函数
Click to show internal directories.
Click to hide internal directories.