database

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCasbinConn

func NewCasbinConn(svc casbinService, dir string, c *CasbinConfig) (e *casbin.SyncedEnforcer, err error)

NewCasbinConn with CasbinConfig and Custom Adapter Start Goroutine to Watching CasbinModel and CasbinConfig

func NewMySQL

func NewMySQL(c *SQLConfig) (db *gorm.DB, err error)

NewMySQL new db and retry connection when has error.

Types

type CasbinAdapter

type CasbinAdapter struct {
	// contains filtered or unexported fields
}

CasbinAdapter casbin适配器

func NewCasbinAdapter

func NewCasbinAdapter(svc casbinService) *CasbinAdapter

NewCasbinAdapter 创建casbin适配器

func (*CasbinAdapter) AddPolicy

func (a *CasbinAdapter) AddPolicy(sec string, ptype string, rule []string) error

AddPolicy adds a policy rule to the storage. This is part of the Auto-Save feature.

func (*CasbinAdapter) LoadPolicy

func (a *CasbinAdapter) LoadPolicy(model model.Model) error

LoadPolicy loads all policy rules from the storage.

func (*CasbinAdapter) RemoveFilteredPolicy

func (a *CasbinAdapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error

RemoveFilteredPolicy removes policy rules that match the filter from the storage. This is part of the Auto-Save feature.

func (*CasbinAdapter) RemovePolicy

func (a *CasbinAdapter) RemovePolicy(sec string, ptype string, rule []string) error

RemovePolicy removes a policy rule from the storage. This is part of the Auto-Save feature.

func (*CasbinAdapter) SavePolicy

func (a *CasbinAdapter) SavePolicy(model model.Model) error

SavePolicy saves all policy rules to the storage.

type CasbinConfig

type CasbinConfig struct {
	Model            string
	Enable           bool
	AutoLoad         bool
	AutoLoadInternal int
}

Config casbin config.

type EFRolePolicy

type EFRolePolicy struct {
	RoleName string
	Router   string
	Method   string
}

type EFUseRole

type EFUseRole struct {
	UserID   int64
	RoleName string
}

type SQLConfig

type SQLConfig struct {
	Driver      string
	DbUser      string
	DbPwd       string
	DbName      string
	DbHost      string
	DbPort      string
	Params      string
	DbPrev      string
	Debug       bool
	Active      int
	Idle        int
	IdleTimeout xtime.Duration
}

Config mysql config.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL