noiseremover

package
v0.0.0-...-13bcc52 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSomethingWentWrong = errors.New("Something went wrong")

	ErrWrongTokenFormat = errors.New("Wrong token format")
	ErrFileNotFound     = errors.New("file not found")

	ErrWrongFileType = errors.New("wrong file type")
	ErrNoSpaceLeft   = errors.New("no space left in storage")
	ErrProcessError  = errors.New("ProcessFile error")
)

Functions

This section is empty.

Types

type BackgroundService

type BackgroundService interface {
	ProcessTicker(ctx context.Context, wg *sync.WaitGroup, duration time.Duration)
	ProcessFile(ctx context.Context, file File) error
}

func NewBackGroundService

func NewBackGroundService(storage Storage, repo Repository) BackgroundService

type DownloadData

type DownloadData struct {
	FullPath string
}

will change with cloud storage

type ExtMime

type ExtMime struct {
	Ext  string
	Mime string
}

type File

type File struct {
	Id           string
	InternalName string
	UploadedName string
	Progress     Progress
}

type Progress

type Progress string
const (
	LogToken = "token"

	ProgressNew              Progress = "new"
	ProgressQueued           Progress = "queued"
	ProgressInProgress       Progress = "in_progress"
	ProgressCompleted        Progress = "completed"
	ProgressErrorEncountered Progress = "error_encountered"
)

type Repository

type Repository interface {
	Add(ctx context.Context, file *File) error
	SetProgress(ctx context.Context, fileId string, progress Progress) error
	GetInfo(ctx context.Context, fileId string) (*File, error)
	GetFilesToProcess(ctx context.Context) ([]File, error)
	QueueFiles(ctx context.Context, counter int64) ([]File, error)
	Close() error
}

type Service

type Service interface {
	Store(ctx context.Context, file multipart.File, fileHeader *multipart.FileHeader) (*File, error)
	Status(ctx context.Context, fileId string) (*StatusData, error)
	Find(ctx context.Context, fileId string) (*DownloadData, error)
}

func NewNoiseRemoverLoggingService

func NewNoiseRemoverLoggingService(service Service) Service

func NewNoiseRemoverService

func NewNoiseRemoverService(storage Storage, repo Repository) Service

type StatusData

type StatusData struct {
	FileId       string
	UploadedName string
	Progress     Progress
	// constants for template
	ProgressNew              Progress
	ProgressInProgress       Progress
	ProgressCompleted        Progress
	ProgressErrorEncountered Progress
}

func NewStatusData

func NewStatusData(fileId, uploadedName string, progress Progress) *StatusData

type Storage

type Storage interface {
	IsEnoughSpaceLeft() (bool, error)
	Store(file multipart.File) (fileName string, err error)
	Find(fileName string) (*DownloadData, error)
	OpenFileUpFolder(filename string) (*os.File, error)
	RemoveFileUpFolder(filename string) error
	CreateFileReadyFolder(filename string) (*os.File, error)
	OpenFileReadyFolder(filename string) (*os.File, error)
	RemoveFileReadyFolder(filename string) error
}

Jump to

Keyboard shortcuts

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