db

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

New returns a DI-injectable constructor for Store.

Types

type Session

type Session struct {
	CreatedAt  time.Time
	ExpiresAt  time.Time
	LastActive time.Time
	Metadata   gas.BasePrincipalMetadata
	ID         string
	Subject    string
	IPAddress  string
	UserAgent  string
}

Session represents a stored session record.

type Store

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

Store is a database-backed session store. It delegates to sqlc-generated queries and selects the correct dialect adapter at init time.

func (*Store) DeleteExpiredSessions

func (s *Store) DeleteExpiredSessions(ctx context.Context, before time.Time) (int64, error)

DeleteExpiredSessions deletes sessions that expired before the given time.

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, id string) error

DeleteSession deletes a session by ID.

func (*Store) DeleteSessionsBySubject

func (s *Store) DeleteSessionsBySubject(ctx context.Context, subject string) error

DeleteSessionsBySubject deletes all sessions for a subject.

func (*Store) ExtendSession

func (s *Store) ExtendSession(ctx context.Context, id string, expiresAt, lastActive time.Time) error

ExtendSession updates the expiry and last active time.

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, id string) (*Session, error)

GetSession retrieves a session by ID.

func (*Store) Init

func (s *Store) Init(serviceName string) error

Init selects the correct sqlc adapter and registers migrations.

func (*Store) InsertSession

func (s *Store) InsertSession(ctx context.Context, sess *Session) error

InsertSession stores a new session.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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