use_tasks

package
v0.0.0-...-a6548e8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTaskHandler

func GetTaskHandler(e *Executor) http.HandlerFunc

func GetTasksHandler

func GetTasksHandler(e *Executor) http.HandlerFunc

func MakeHandler

func MakeHandler(taskService TaskService, timeoutsService TimeoutsService, distributer Distributer) http.Handler

func PostTaskHandler

func PostTaskHandler(e *Executor) http.HandlerFunc

Types

type Distributer

type Distributer interface {
	Distribute(task *pb.Task) error
}

type Executor

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

func NewExecutor

func NewExecutor(tasksService TaskService, timeoutsService TimeoutsService, distributer Distributer) *Executor

func (*Executor) GetTask

func (e *Executor) GetTask(taskId int64, userId int64) (GetTaskResp, error)

func (*Executor) GetTasks

func (e *Executor) GetTasks(userId int64, limit, offset int) (GetTasksResp, error)

func (*Executor) PostTask

func (e *Executor) PostTask(body PostTaskBody, userId int64) (PostTaskResp, error)

type GetTaskResp

type GetTaskResp struct {
	Task TaskSource `json:"task"`
}

type GetTasksResp

type GetTasksResp struct {
	Tasks []TaskSource `json:"tasks"`
}

type PostTaskBody

type PostTaskBody struct {
	Expression string `json:"expression" validate:"required"`
}

type PostTaskResp

type PostTaskResp struct {
	Task TaskSource `json:"task"`
}

type TaskService

type TaskService interface {
	Add(service.Task) (int64, error)
	GetById(id int64) (service.Task, error)
	GetAllForUser(userId int64, limit, offset int) ([]service.Task, error)
}

type TaskSource

type TaskSource struct {
	Id         int64   `json:"id"`
	Expression string  `json:"expression"`
	Result     float64 `json:"result"`
	Status     string  `json:"status"`
	CreateTime string  `json:"createTime"`
}

type TimeoutsService

type TimeoutsService interface {
	GetForUser(id int64) (service.Timeouts, error)
}

Jump to

Keyboard shortcuts

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