routing

package
v0.19.985 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForceReplica

func ForceReplica(db *gorm.DB) *gorm.DB

func IsForceReplica

func IsForceReplica(ctx context.Context) bool

func IsWithoutReplica

func IsWithoutReplica(ctx context.Context) bool

func Primary

func Primary(db *gorm.DB) *gorm.DB

func Replica

func Replica(db *gorm.DB) *gorm.DB

func ResolveTable

func ResolveTable(db *gorm.DB, model interface{}) string

func UseReplica

func UseReplica(ctx context.Context) bool

func WithDecision

func WithDecision(ctx context.Context, p Pool) context.Context

func WithForceReplica

func WithForceReplica(ctx context.Context) context.Context

func WithReplica

func WithReplica(ctx context.Context) context.Context

func WithoutReplica

func WithoutReplica(ctx context.Context) context.Context

Types

type ACLBuilder

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

func NewACLBuilder

func NewACLBuilder(db *gorm.DB) *ACLBuilder

func (*ACLBuilder) Allow

func (b *ACLBuilder) Allow(models ...interface{}) *ACLBuilder

func (*ACLBuilder) Build

func (b *ACLBuilder) Build() *TableACL

func (*ACLBuilder) Deny

func (b *ACLBuilder) Deny(models ...interface{}) *ACLBuilder

type ConnPool

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

func NewConnPool

func NewConnPool(primary, replica *sql.DB) *ConnPool

func (*ConnPool) BeginTx

func (p *ConnPool) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

func (*ConnPool) ExecContext

func (p *ConnPool) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*ConnPool) GetDBConn

func (p *ConnPool) GetDBConn() (*sql.DB, error)

func (*ConnPool) PrepareContext

func (p *ConnPool) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)

func (*ConnPool) QueryContext

func (p *ConnPool) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func (*ConnPool) QueryRowContext

func (p *ConnPool) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row

type Plugin

type Plugin struct {
	ACL         *TableACL
	BypassOptIn bool
	Logger      *zap.Logger
}

func (*Plugin) Initialize

func (p *Plugin) Initialize(db *gorm.DB) error

func (*Plugin) Name

func (p *Plugin) Name() string

type Pool

type Pool string
const (
	PoolPrimary Pool = "primary"
	PoolReplica Pool = "replica"
)

func DecisionFromContext

func DecisionFromContext(ctx context.Context) Pool

type TableACL

type TableACL struct {
	Allow map[string]struct{}
	Deny  map[string]struct{}
}

func NewTableACL

func NewTableACL(allow, deny []string) *TableACL

func (*TableACL) AllowsReplica

func (a *TableACL) AllowsReplica(table string) bool

Jump to

Keyboard shortcuts

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