service

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTaskNotFound         = apperr.New("task_not_found", apperr.WithTextTranslate(translator.Translate{translator.RU: "Задача не найдена", translator.EN: "Task not found"}), apperr.WithCode(code.NotFound))
	ErrTaskTypeNotFound     = apperr.New("task_type_not_found", apperr.WithTextTranslate(translator.Translate{translator.RU: "Тип задачи не найден", translator.EN: "Task's type not found"}), apperr.WithCode(code.NotFound))
	ErrTaskCannotStop       = apperr.New("task_cannot_stop", apperr.WithTextTranslate(translator.Translate{translator.RU: "Невозможно остановить завершенную задачу", translator.EN: "Cannot stop a completed task"}), apperr.WithCode(code.NotFound))
	ErrTaskUnableRerun      = apperr.New("task_unable_rerun", apperr.WithTextTranslate(translator.Translate{translator.RU: "Невозможно запустить незавершенную задачу", translator.EN: "Unable to rerun an unfinished task"}), apperr.WithCode(code.NotFound))
	ErrTaskFileNotFound     = apperr.New("task_file_not_found", apperr.WithTextTranslate(translator.Translate{translator.RU: "Файл не найден", translator.EN: "File not found"}), apperr.WithCode(code.NotFound))
	ErrTaskFileStillOngoing = apperr.New("task_file_process", apperr.WithTextTranslate(translator.Translate{translator.RU: "Задача все еще выполняется", translator.EN: "The task is still ongoing"}), apperr.WithCode(code.NotFound))
)

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	Export(ctx context.Context, data []byte) (*model3.Message, error)
	Import(ctx context.Context, data []byte) (*model3.Message, error)
	MassUpdate(ctx context.Context, data []byte) (*model3.Message, error)
	MassDelete(ctx context.Context, data []byte) (*model3.Message, error)
}

type Consumers

type Consumers map[string]Consumer

type ITaskService

type ITaskService interface {
	Trx(db *gorm.DB) ITaskService
	List(ctx context.Context, m *model2.Meta[model.Task]) error
	GetFull(ctx context.Context, taskID *int, statuses ...string) ([]model.Task, error)
	Update(ctx context.Context, id int, input TaskUpdateInput) error
	UpdateStatus(ctx context.Context, status string, ids ...int) error
	Create(ctx context.Context, input TaskCreateInput) (*model.Task, error)
	GetById(ctx context.Context, id int) (*model.Task, error)
	Stop(ctx context.Context, id int) error
	Rerun(ctx context.Context, id int) (*model.Task, error)
	RunTasks(ctx context.Context, statuses []string, ids ...int) error
	Download(ctx context.Context, id int) (string, error)
}

type Queue

type Queue interface {
	Run(data runner.Data)
	Stop(id int)
}

type TaskCreateInput

type TaskCreateInput struct {
	Name string
	Type string
	Data []byte
}

type TaskService

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

func NewTaskService

func NewTaskService(
	taskRepository repository.ITaskRepository,
	services Consumers,
	queue Queue,
) TaskService

func (TaskService) Create

func (s TaskService) Create(ctx context.Context, input TaskCreateInput) (*model.Task, error)

func (TaskService) Download

func (s TaskService) Download(ctx context.Context, id int) (string, error)

func (TaskService) GetById

func (s TaskService) GetById(ctx context.Context, id int) (*model.Task, error)

func (TaskService) GetFull

func (s TaskService) GetFull(ctx context.Context, taskID *int, statuses ...string) ([]model.Task, error)

func (TaskService) List

func (s TaskService) List(ctx context.Context, m *model2.Meta[model.Task]) error

func (TaskService) Rerun

func (s TaskService) Rerun(ctx context.Context, id int) (*model.Task, error)

func (TaskService) RunTasks

func (s TaskService) RunTasks(ctx context.Context, statuses []string, ids ...int) error

func (TaskService) Stop

func (s TaskService) Stop(ctx context.Context, id int) error

func (TaskService) Trx

func (s TaskService) Trx(db *gorm.DB) ITaskService

func (TaskService) Update

func (s TaskService) Update(ctx context.Context, id int, input TaskUpdateInput) error

func (TaskService) UpdateStatus

func (s TaskService) UpdateStatus(ctx context.Context, status string, ids ...int) error

type TaskUpdateInput

type TaskUpdateInput struct {
	Status *string
	Output *model3.Message
}

Jump to

Keyboard shortcuts

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