routing

package
v0.19.1237 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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