tasks

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

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

func NewExecutor

func NewExecutor(task *models.Task, logger *zap.Logger) *Executor

func (*Executor) Run

func (s *Executor) Run()

ExecuteTask executes a task This method is used by the cron to execute tasks.

type Repo

type Repo interface {
	GetAll(ctx context.Context) ([]*models.Task, error)
	GetByID(ctx context.Context, id string) (*models.Task, error)
	GetByNamespace(ctx context.Context, namespace string) ([]*models.Task, error)
	CreateOne(ctx context.Context, task *models.TaskPayload) (string, error)
	UpdateStatus(ctx context.Context, id string, paused bool) error
	Delete(ctx context.Context, id string) error
}

Repo is the interface that wraps the required repository methods. Any underlying database repository should implement these methods.

type Scheduler

type Scheduler interface {
	ScheduleTask(task *models.Task)
	DiscardTaskNow(id string)
}

Scheduler is the interface that wraps the scheduler methods.

type Service

type Service interface {
	GetAll(ctx context.Context) ([]*models.Task, error)
	GetByNamespace(ctx context.Context, namespace string) ([]*models.Task, error)
	Create(ctx context.Context, task *models.TaskPayload) (string, int, error)
	ToggleStatus(ctx context.Context, id string) error
	Delete(ctx context.Context, id string) error
}

Service is the interface that wraps tasks service methods.

func New

func New(repo Repo, scheduler Scheduler) Service

New returns a new instance of the tasks service.

Directories

Path Synopsis
store

Jump to

Keyboard shortcuts

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