service

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeouts = Timeouts{}
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Id             int64
	Active         bool
	Ping           int64
	MaxThreads     int
	RunningThreads int
}

type AgentService

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

func NewAgentService

func NewAgentService(pool *pgxpool.Pool) (*AgentService, error)

func (*AgentService) Add

func (as *AgentService) Add(agent Agent) (int64, error)

func (*AgentService) Delete

func (as *AgentService) Delete(id int64) error

func (*AgentService) DisactivateAll

func (as *AgentService) DisactivateAll() error

func (*AgentService) GetAll

func (as *AgentService) GetAll(limit, offset int) ([]Agent, error)

func (*AgentService) GetById

func (as *AgentService) GetById(id int64) (Agent, error)

func (*AgentService) Update

func (as *AgentService) Update(agent Agent) error

type Task

type Task struct {
	Id         int64
	UserId     int64
	Executor   int64
	Expression string
	Result     float64
	Status     TaskStatus
	CreateTime time.Time
}

type TaskService

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

func NewTaskService

func NewTaskService(pool *pgxpool.Pool) (*TaskService, error)

func (*TaskService) Add

func (ts *TaskService) Add(task Task) (int64, error)

func (*TaskService) Delete

func (ts *TaskService) Delete(id int64) error

func (*TaskService) GetAllForUser

func (ts *TaskService) GetAllForUser(userId int64, limit, offset int) ([]Task, error)

func (*TaskService) GetAllPending

func (ts *TaskService) GetAllPending() ([]TaskWithTimeouts, error)

func (*TaskService) GetById

func (ts *TaskService) GetById(id int64) (Task, error)

func (*TaskService) GetExecutingForAgent

func (ts *TaskService) GetExecutingForAgent(id int64) ([]TaskWithTimeouts, error)

func (*TaskService) SetPendingForDisactiveAgents

func (ts *TaskService) SetPendingForDisactiveAgents() error

func (*TaskService) SetUnexecutingForAgent

func (ts *TaskService) SetUnexecutingForAgent(id int64) error

func (*TaskService) Update

func (ts *TaskService) Update(task Task) error

type TaskStatus

type TaskStatus string
var (
	TaskStatusPending   TaskStatus = "pending"
	TaskStatusExecuting TaskStatus = "executing"
	TaskStatusSuccess   TaskStatus = "success"
	TaskStatusError     TaskStatus = "error"
)

type TaskWithTimeouts

type TaskWithTimeouts struct {
	Task
	Timeouts
}

type Timeouts

type Timeouts struct {
	UserId int64
	Add    uint
	Sub    uint
	Mul    uint
	Div    uint
}

type TimeoutsSerice

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

func NewTimeoutsService

func NewTimeoutsService(pool *pgxpool.Pool) (*TimeoutsSerice, error)

func (*TimeoutsSerice) Add

func (ts *TimeoutsSerice) Add(timeouts Timeouts) error

func (*TimeoutsSerice) GetForUser

func (ts *TimeoutsSerice) GetForUser(userId int64) (Timeouts, error)

func (*TimeoutsSerice) Put

func (ts *TimeoutsSerice) Put(timeouts Timeouts) error

Add if not exists, update if exists

func (*TimeoutsSerice) Update

func (ts *TimeoutsSerice) Update(timeouts Timeouts) error

type User

type User struct {
	Id             int64
	Login          string
	HashedPassword string
}

type UserService

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

func NewUserService

func NewUserService(pool *pgxpool.Pool) (*UserService, error)

func (*UserService) Add

func (us *UserService) Add(user User) (int64, error)

func (*UserService) GetById

func (us *UserService) GetById(id int64) (User, error)

func (*UserService) GetByLogin

func (us *UserService) GetByLogin(login string) (User, error)

Jump to

Keyboard shortcuts

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