session

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyFrom  = contextx.From[tSessionKey, string]
	KeyMust  = contextx.Must[tSessionKey, string]
	KeyWith  = contextx.With[tSessionKey, string]
	KeyCarry = contextx.Carry[tSessionKey, string]
)

Functions

func Carry added in v0.0.4

func Carry(session Session) contextx.Carrier

Carry returns context carrier

func Register added in v0.2.2

func Register(session string, cats ...builder.Catalog)

func With added in v0.0.4

func With(ctx context.Context, session Session) context.Context

With injects Session

Types

type AdaptorOption added in v0.1.18

type AdaptorOption struct {
	ReadOnly bool
}

type AdaptorOptionApplier added in v0.2.1

type AdaptorOptionApplier func(*AdaptorOption)

func ReadOnly added in v0.0.3

func ReadOnly() AdaptorOptionApplier

type Session added in v0.0.3

type Session interface {

	// Name returns session name. this is global unique identifier for Session
	Name() string
	// T picks table from session
	T(any) builder.Table
	// Tx exec query
	Tx(context.Context, func(context.Context) error) error
	// Adaptor returns session adaptor
	Adaptor(...AdaptorOptionApplier) adaptor.Adaptor
}

Session is a logical isolation unit and operational handle for database adapters. eg:

a specific MySQL database
a specific search_path in same PostgreSQL database
a particular SQLite database file.

func For added in v0.0.3

func For(ctx context.Context, m any) (Session, bool)

For retrieves Session by session name or table

func From added in v0.0.4

func From(ctx context.Context, name string) (Session, bool)

From retrieve Session from ctx by Session.Name

func Must added in v0.2.1

func Must(ctx context.Context, name string) Session

func MustFor added in v0.2.1

func MustFor(ctx context.Context, m any) Session

func New added in v0.0.3

func New(a adaptor.Adaptor, name string) Session

func NewReadonly added in v0.2.1

func NewReadonly(rw adaptor.Adaptor, ro adaptor.Adaptor, name string) Session

Jump to

Keyboard shortcuts

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