tasker

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShutdown = errors.New("shutdown")
)

Functions

This section is empty.

Types

type Database

type Database interface {
	TasksCreate(fileName string, uid int64) (int64, error)
	TasksSetStatusInProgress(id int64) error
	TasksSetStatusError(id int64, errorText string) error
	TasksSetStatusSuccess(id, musicID int64) error

	// MusicIsExists returns true if db already has wor with that data
	MusicIsExists(title, album, artist string) bool
	// MusicGetAlbumPicture returns true if album already has picture
	// also returns name of the picture file
	MusicGetAlbumPicture(album, artist string) (bool, string, error)
	// MusicCreate creates new music row in the DB
	MusicCreate(fileNameMiddle, fileNameHigh, picture string, duration, uid int64,
		musicInfo *music.Music, preData *dbmodels.PreMusicData) (int64, error)
}

Database methods for tasker

type ProcessSettings added in v0.0.2

type ProcessSettings struct {
	Bitrate *settings.Tasker
	PreData *dbmodels.PreMusicData
}

ProcessSettings contains bitrate settings and preload file

type Storage

type Storage interface {
	// GetTmpPathToFile returns full path of the tmp file
	GetTmpPathToFile(fileName string) string
	// GenerateNewTmpFileName returns name of the new tmp file with extension
	GenerateNewTmpFileName(ext string) string
	// GenerateNewPathToTmpFile generetes full path to the new tmp file
	GenerateNewPathToTmpFile(ext string) string
	// RemoveTmpFile removes file in the tmp storage
	RemoveTmpFile(tmpFile string) error
	// RemovePrefixFile removes file in the prefix storage
	RemovePrefixFile(fileName string) error
	// CopyFromTmpToPrefixStorage moves file from tmp to prefix storage
	CopyFromTmpToPrefixStorage(tmpFile string) (string, error)
}

Storage file system storage

type Task

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

Task is an element of the tasker

type Tasker

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

Tasker parses files and moves them in the storage

func New

func New(conf *config.Tasker, log *zerolog.Logger, st Storage, db Database) (*Tasker, error)

New creates new tasker

func (*Tasker) ApplySettings added in v0.0.2

func (t *Tasker) ApplySettings(s interface{}) error

ApplySettings applies the new default bitrate settings

func (*Tasker) CheckSettingsIsValid added in v0.0.2

func (*Tasker) CheckSettingsIsValid(s interface{}) error

CheckSettingsIsValid checks is this settings valid

func (*Tasker) GetSettingsPrefix added in v0.0.2

func (*Tasker) GetSettingsPrefix() string

GetSettingsPrefix returns prefix of the settings name

func (*Tasker) ProcessImageFile added in v0.0.2

func (t *Tasker) ProcessImageFile(log *zerolog.Logger, fileName string) (string, error)

ProcessImageFile processes and creates new image file returns name of the new file

func (*Tasker) ProcessMusicFile

func (t *Tasker) ProcessMusicFile(log *zerolog.Logger, fileName string, uid int64, sets ...*ProcessSettings) (
	taskID int64, result <-chan error, err error,
)

ProcessMusicFile processes and creates new music file returns ID of the Task and result channel

func (*Tasker) Shutdown

func (t *Tasker) Shutdown(wait time.Duration)

Jump to

Keyboard shortcuts

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