service

package
v0.0.0-...-bf7cbd6 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthService

func NewAuthService(db Database, logger logger.Logger, repo AuthRepository, pwv PasswordValidator) domain.AuthService

func NewCheevosService

func NewCheevosService(db Database, logger logger.Logger, repo CheevosRepository) domain.CheevosService

func NewRosterService

func NewRosterService(db Database, email Emailer, logger logger.Logger, repo RosterRepository) domain.RosterService

Types

type AuthRepository

type AuthRepository interface {
	GetUser(ctx context.Context, tx pg.Tx, u *domain.User, id string) error
	InsertUser(ctx context.Context, tx pg.Tx, u *domain.User, hashedPassword string) error
}

type CheevosRepository

type CheevosRepository interface {
	GetCheevo(ctx context.Context, tx pg.Tx, cheevo *domain.Cheevo, id string) error
	InsertAward(ctx context.Context, tx pg.Tx, award *domain.Award) error
	InsertCheevo(ctx context.Context, tx pg.Tx, cheevo *domain.Cheevo) error
}

type Database

type Database interface {
	// WithTx is responsible for opening a transaction boundary on the parent
	// database and calling the provided function, passing the transaction in for
	// use by the service layer. If an error is returned from the function
	// closure, the transaction is rolled back and WithTx returns an error as
	// well.
	WithTx(context.Context, func(ctx context.Context, tx pg.Tx) error) error
}

Database represents a connection to a persistence layer. A Database is only responsible for opening a transaction which is then responsible for all of the heavy lifting.

type Emailer

type Emailer interface {
	SendInvitation(ctx context.Context, email, code string) error
}

type PasswordValidator

type PasswordValidator interface {
	Validate(p password.Password) error
}

type RosterRepository

type RosterRepository interface {
	DeleteInvitationByCode(ctx context.Context, tx pg.Tx, hashedCode string) error
	GetInvitation(ctx context.Context, tx pg.Tx, i *domain.Invitation, id string) error
	GetInvitationByCode(ctx context.Context, tx pg.Tx, i *domain.Invitation, hashedCode string) error
	InsertInvitation(ctx context.Context, tx pg.Tx, i *domain.Invitation, hashedCode string) error
	UpdateInvitation(ctx context.Context, tx pg.Tx, i *domain.Invitation, hashedCode string) error
	GetMembership(ctx context.Context, tx pg.Tx, m *domain.Membership, orgID, userID string) error
	InsertMembership(ctx context.Context, tx pg.Tx, m *domain.Membership) error
	InsertOrganization(ctx context.Context, tx pg.Tx, org *domain.Organization) error
}

Jump to

Keyboard shortcuts

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