song

package
v0.0.0-...-c05fae0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	// CreateSong creates a new song with the specified data.
	// An existing song.UUID must be ignored.
	// This method must set song.UUID, song.CreatedAt, and song.UpdatedAt appropriately.
	CreateSong(ctx context.Context, song *model.Song) error

	// GetSong fetches the song with the specified UUID.
	// If no such song exists, core.ErrNotFound will be returned.
	GetSong(ctx context.Context, id uuid.UUID) (model.Song, error)

	// FindSongs returns all songs matching the specified query.
	// Results are paginated with limit and offset.
	// The second return value contains the total (unpaginated) number of songs.
	//
	// If no songs match, no error will be returned.
	FindSongs(ctx context.Context, limit int, offset int64) ([]model.Song, int64, error)

	// UpdateSong saves Updates for the specified song.
	// The song's UUID must already exist in the database, otherwise e core.ErrNotFound
	// will be returned.
	UpdateSong(ctx context.Context, song *model.Song) error

	// DeleteSong deletes the song with the specified UUID.
	// If no such song exists, the first return value will be false.
	DeleteSong(ctx context.Context, id uuid.UUID) (bool, error)
}

A Repository is an interface for storing songs.

func NewDBRepository

func NewDBRepository(logger *slog.Logger, db pgxutil.DB) Repository

NewDBRepository creates a new Repository backed by the specified database connection. db can be a single connection or a connection pool.

func NewFakeRepository

func NewFakeRepository() Repository

NewFakeRepository returns a new Repository implementation backed by an in-memory map. Not all features (especially complex queries) are supported on fake repositories.

type Service

type Service interface {
	// ParseArtists sets song.Artists based on other song fields.
	// This method should be used to process songs parsed from a TXT source where multiple artists are not supported.
	ParseArtists(ctx context.Context, song *model.Song)

	// Prepare prepares song for TXT serialization.
	// This includes merging multiple artists and setting appropriate file names.
	Prepare(ctx context.Context, song *model.Song)
}

A Service implements modification logic for Songs.

func NewService

func NewService() Service

NewService creates a new Service.

Jump to

Keyboard shortcuts

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