storage

package
v0.0.0-...-0361e45 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBQuery

type DBQuery interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	PingContext(ctx context.Context) error
	Begin() (*sql.Tx, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	Prepare(query string) (*sql.Stmt, error)
}

type PostgresStorage

type PostgresStorage struct {
	DB    DBQuery
	RawDB *sql.DB
	// contains filtered or unexported fields
}

func NewPostgresStorage

func NewPostgresStorage(dsn string) (*PostgresStorage, error)

NewPostgresStorage PostgresStorage настройка подключения к БД

func (*PostgresStorage) Ping

func (p *PostgresStorage) Ping(ctx context.Context) error

type SessionManager

type SessionManager interface {
	Add(token string, expire time.Time)
	IsValid(token string) bool
}

func NewSessionStorage

func NewSessionStorage() SessionManager

type SessionStorage

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

SessionStorage данные по авторизованным пользователям

func (*SessionStorage) Add

func (s *SessionStorage) Add(token string, expire time.Time)

func (*SessionStorage) IsValid

func (s *SessionStorage) IsValid(token string) bool

type Transaction

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

func NewTransaction

func NewTransaction(db DBQuery) (*Transaction, error)

NewTransaction Открывает новую транзакцию

func (*Transaction) AddError

func (t *Transaction) AddError(e error)

func (*Transaction) Commit

func (t *Transaction) Commit() error

func (*Transaction) Error

func (t *Transaction) Error() []error

func (*Transaction) QueryRowContext

func (t *Transaction) QueryRowContext(ctx context.Context, query string, args ...any) (*sql.Row, error)

func (*Transaction) Rollback

func (t *Transaction) Rollback() error

func (*Transaction) Tx

func (t *Transaction) Tx() *sql.Tx

type TxDBQuery

type TxDBQuery interface {
	QueryRowContext(ctx context.Context, query string, args ...any) (*sql.Row, error)
	Rollback() error
	Commit() error
	Tx() *sql.Tx
	Error() []error
	AddError(e error)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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