session

package
v0.0.0-...-36bb7bb Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const UNIQUE_VIOLATION = "23505"

Variables

View Source
var (
	ErrSessionNotFound = errors.New("session not found")
	ErrSessionExists   = errors.New("session already exists")
)

Functions

func NewSeed

func NewSeed() uint16

Types

type PgSessionRepo

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

func NewPgSessionRepo

func NewPgSessionRepo(db *pgxpool.Pool) *PgSessionRepo

func (*PgSessionRepo) CreateSession

func (repo *PgSessionRepo) CreateSession(ctx context.Context, s Session) (uint64, error)

func (*PgSessionRepo) GetSession

func (repo *PgSessionRepo) GetSession(ctx context.Context, id uint64) (Session, error)

func (*PgSessionRepo) GetSessionByGroupID

func (repo *PgSessionRepo) GetSessionByGroupID(
	ctx context.Context,
	groupID uint64,
) (Session, error)

Get most recent session by group ID

func (*PgSessionRepo) UpdateShuffle

func (repo *PgSessionRepo) UpdateShuffle(ctx context.Context, id uint64, seed uint16) error

func (*PgSessionRepo) UserInSession

func (repo *PgSessionRepo) UserInSession(
	ctx context.Context,
	id uint64,
	email string,
) (bool, error)

type Session

type Session struct {
	ID          uint64           `json:"id"           db:"id"`
	GroupID     uint64           `json:"group_id"     db:"group_id"`
	CreateDate  types.CustomTime `json:"create_date"  db:"create_date"`
	ShuffleSeed uint16           `json:"shuffle_seed" db:"shuffle_seed"`
}

func NewSession

func NewSession(groupID uint64) Session

type SessionService

type SessionService interface {
	GetSession(ctx context.Context, id uint64) (Session, error)
	GetSessionByGroupID(ctx context.Context, groupID uint64) (Session, error)
	CreateSession(ctx context.Context, s Session) (uint64, error)
	UpdateShuffle(ctx context.Context, id uint64, seed uint16) error
	UserInSession(ctx context.Context, id uint64, email string) (bool, error)
}

Jump to

Keyboard shortcuts

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