gormdb

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2023 License: MIT Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *gorm.DB
View Source
var Enforcer casbin.IEnforcer

Functions

This section is empty.

Types

type CasbinRule added in v0.1.1

type CasbinRule struct {
	PType string `json:"pType" gorm:"size:100;"`
	V0    string `json:"v0" gorm:"size:100;"`
	V1    string `json:"v1" gorm:"size:100;"`
	V2    string `json:"v2" gorm:"size:100;"`
	V3    string `json:"v3" gorm:"size:100;"`
	V4    string `json:"v4" gorm:"size:100;"`
	V5    string `json:"v5" gorm:"size:100;"`
}

func (*CasbinRule) TableName added in v0.1.1

func (*CasbinRule) TableName() string

type Configure

type Configure interface {
	Init(*gorm.Config, func(string) gorm.Dialector) (*gorm.DB, error)
}

func NewConfigure

func NewConfigure(
	dsn string,
	maxIdleConns,
	maxOpenConns,
	connMaxIdleTime,
	connMaxLifetime int,
	registers []ResolverConfigure) Configure

NewConfigure 初始化 Configure

type DBConfig

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

func (*DBConfig) Init

func (e *DBConfig) Init(config *gorm.Config, open func(string) gorm.Dialector) (*gorm.DB, error)

Init 获取db,⚠️注意:读写分离只能配置一组

type DBResolverConfig

type DBResolverConfig struct {
	Sources  []string `yaml:"sources"`
	Replicas []string `yaml:"replicas"`
	Policy   string   `yaml:"policy"`
	Tables   []string `yaml:"tables"`
}

type Database

type Database struct {
	Driver          string             `yaml:"driver"`
	Source          string             `yaml:"source"`
	ConnMaxIdleTime int                `yaml:"connMaxIdleTime"`
	ConnMaxLifeTime int                `yaml:"connMaxLifeTime"`
	MaxIdleConns    int                `yaml:"maxIdleConns"`
	MaxOpenConns    int                `yaml:"maxOpenConns"`
	Registers       []DBResolverConfig `yaml:"registers"`
	CasbinModel     string             `yaml:"casbinModel"`
}

func (*Database) Init

func (e *Database) Init()

type ResolverConfigure

type ResolverConfigure interface {
	Init(*dbresolver.DBResolver, func(string) gorm.Dialector) *dbresolver.DBResolver
}

func NewResolverConfigure

func NewResolverConfigure(sources, replicas []string, policy string, tables []string) ResolverConfigure

NewResolverConfigure 初始化 ResolverConfigure

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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