service

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Guess

type Guess interface {
	CountFromDate(ctx context.Context, from time.Time) (int, error)

	FindLatest(ctx context.Context) ([]domain.Guess, error)
	FindByUser(ctx context.Context, userId, limit, page int) (domain.Paged[domain.Guess], error)
	FindById(ctx context.Context, id string) (domain.Guess, error)
	FindTopFromDate(ctx context.Context, from time.Time, limit int) ([]domain.GuessExtended, error)

	CreateAndUpdateUserElo(ctx context.Context, userId int, input domain.GuessCreate) (int, domain.Guess, error)
}

func NewGuess

func NewGuess(guesses repo.Guesses, users repo.Users, uow *uow.UnitOfWork) Guess

type Players

type Players interface {
	FindRandom(ctx context.Context) (domain.Player, error)
	Find(ctx context.Context, limit, page int) ([]domain.Player, error)
	CreateMany(ctx context.Context, ids []domain.PlayerCreate) (int64, error)
}

func NewPlayer

func NewPlayer(repo repo.Players) Players

type Replays added in v0.11.0

type Replays interface {
	AnonymizeAndPresign(ctx context.Context, data []byte, filename string, ttl time.Duration) (string, error)
	CreateAndPresign(ctx context.Context, data []byte, size int64, filename string, ttl time.Duration) (string, error)
	CreateForSubmission(ctx context.Context, data []byte, size int64, scoreId int) error
	PresignSubmission(ctx context.Context, scoreId int, ttl time.Duration) (string, error)
}

func NewReplays added in v0.11.0

func NewReplays(cfg *config.Config, s3 *minio.Client) Replays

type Rooms

type Rooms interface {
	FindByUserUnguessed(ctx context.Context, userId int) (domain.Room, error)
	FindRandomScore(ctx context.Context, accessToken string) (osuapi.Score, error)
	FindByUser(ctx context.Context, userId int, accessToken string) (domain.RoomExtended, error)
	FindOrDeleteExpired(ctx context.Context, id, accessToken string, userId int) (domain.RoomExtended, error)

	UpdateGuessID(ctx context.Context, id string, guessId string) error
	UpdateReplayURL(ctx context.Context, id string, replayURL string) error

	SetNext(ctx context.Context, id string, userId, playerId, scoreId int) (refill domain.RefillResult, room domain.Room, err error)
	Create(ctx context.Context, playerId, userId, scoreId int, kind domain.RoomKind) (domain.RefillResult, domain.Room, error)

	DeleteById(ctx context.Context, id string) error
	DeleteByUser(ctx context.Context, userId int) error
	DeleteByUserUnguessed(ctx context.Context, userId int) error

	RefillForUser(ctx context.Context, userId int, sub uint) (domain.RefillResult, error)

	// works for now, but should be moved to a separate service
	GetScore(ctx context.Context, accessToken string, scoreId int) (osuapi.Score, error)
}

func NewRooms

func NewRooms(
	repo repo.Rooms, users repo.Users, players repo.Players, guessesSvc Guess,
	oapi *osuapi.Client, rdb *redis.Client, uow *uow.UnitOfWork,
) Rooms

type Sessions

type Sessions interface {
	Find(ctx context.Context, id string) (domain.Session, error)
	FindWithUser(ctx context.Context, id string) (domain.SessionExtended, error)

	DeleteByUser(ctx context.Context, osuId int) error
	UpdateTokens(ctx context.Context, id, accessToken, refreshToken string, expiresAt time.Time) error
	Create(ctx context.Context, osuId int, accessToken, refreshToken string, expiresAt time.Time) (domain.Session, error)
}

func NewSessions

func NewSessions(cfg *config.Config, repo repo.Sessions) Sessions

type Submissions

type Submissions interface {
	Create(ctx context.Context, input domain.SubmissionCreate) (domain.Submission, error)
	Delete(ctx context.Context, id string) error
	SetAccepted(ctx context.Context, id string) error

	FindRandom(ctx context.Context, userId int) (domain.Submission, error)
	FindRandomWithScore(ctx context.Context, userId int, accessToken string) (osuapi.Score, string, error)
	FindByUser(ctx context.Context, userId int, accepted bool) ([]domain.Submission, error)
	FindByID(ctx context.Context, id string) (domain.Submission, error)
	FindByScoreID(ctx context.Context, scoreId int) (domain.Submission, error)
	Find(ctx context.Context, accepted bool, limit, page int) ([]domain.SubmissionExtended, error)
}

func NewSubmissions

func NewSubmissions(repo repo.Submissions, client *osuapi.Client) Submissions

type User

type User interface {
	Upsert(ctx context.Context, osuId int, username, avatarURL, countryCode string) error

	FindByOsuID(ctx context.Context, osuId int) (domain.User, error)
	FindTop(ctx context.Context, limit, page int) (domain.Paged[domain.UserExtended], error)
}

func NewUser

func NewUser(repo repo.Users) User

Jump to

Keyboard shortcuts

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