server

package
v0.0.0-...-96dbe26 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2020 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// For use with functions that take an expiration time.
	NoExpiration time.Duration = -1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CachedTaskInfo

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

CachedTaskInfo 每一个Task,对应一个缓存对象,所有与它关联的操作都由一个Goroutine来处理

func NewCachedTaskInfo

func NewCachedTaskInfo(s *Server, t *CreateTask) *CachedTaskInfo

NewCachedTaskInfo ...

func (*CachedTaskInfo) EqualCmp

func (ct *CachedTaskInfo) EqualCmp(t *CreateTask) bool

EqualCmp ...

func (*CachedTaskInfo) Query

func (ct *CachedTaskInfo) Query() *TaskInfo

Query ...

func (*CachedTaskInfo) Start

func (ct *CachedTaskInfo) Start()

Start 使用一个Goroutine来启动任务操作

type CreateTask

type CreateTask struct {
	ID            string   `json:"id"`
	DispatchFiles []string `json:"dispatchFiles"`
	DestIPs       []string `json:"destIPs"`
}

CreateTask 创建分发任务

type DispatchFile

type DispatchFile struct {
	FileName        string  `json:"filename"`
	PercentComplete float32 `json:"-"`
}

DispatchFile 单个文件分发状态

type DispatchInfo

type DispatchInfo struct {
	Status          string  `json:"status"`
	PercentComplete float32 `json:"percentComplete"`

	StartedAt  time.Time `json:"startedAt"`
	FinishedAt time.Time `json:"finishedAt"`

	DispatchFiles []*DispatchFile `json:"dispatchFiles"`
}

DispatchInfo 单个IP的分发信息

type Server

type Server struct {
	common.BaseService
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg *common.Config) (*Server, error)

func (*Server) CancelTask

func (s *Server) CancelTask(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

CancelTask DELETE /api/v1/server/tasks/:id

func (*Server) CheckAllClient

func (s *Server) CheckAllClient(ips []string) map[string]string

给所有客户端是否存在

func (*Server) CheckAllClientIp

func (s *Server) CheckAllClientIp(ips []string)

给所有客户端发送停止命令

func (*Server) CreateTask

func (s *Server) CreateTask(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

CreateTask POST /api/v1/server/tasks

func (*Server) CreateTaskNoHttp

func (s *Server) CreateTaskNoHttp(t *CreateTask) error

func (*Server) Json

func (svc *Server) Json(r int, s interface{}, w http.ResponseWriter)

func (*Server) OnStart

func (s *Server) OnStart(cfg *common.Config, e *httprouter.Router) error

func (*Server) OnStop

func (s *Server) OnStop(c *common.Config, e *httprouter.Router)

func (*Server) QueryTask

func (s *Server) QueryTask(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

QueryTask GET /api/v1/server/tasks/:id

func (*Server) QueryTaskNoHttp

func (s *Server) QueryTaskNoHttp(id string) (*TaskInfo, error)

func (*Server) ReportTask

func (s *Server) ReportTask(w http.ResponseWriter, r *http.Request, ps httprouter.Params)

ReportTask POST /api/v1/server/tasks/status

func (*Server) String

func (svc *Server) String(r int, s string, w http.ResponseWriter)

type TaskInfo

type TaskInfo struct {
	ID     string `json:"id"`
	Status string `json:"status"`

	StartedAt  time.Time `json:"startedAt"`
	FinishedAt time.Time `json:"finishedAt"`

	DispatchInfos map[string]*DispatchInfo `json:"dispatchInfos,omitempty"`
}

TaskInfo 查询分发任务

type TaskStatus

type TaskStatus int

TaskStatus 任务状态

const (
	TaskNotExist TaskStatus = iota
	TaskExist
	TaskInit
	TaskFailed
	TaskCompleted
	TaskInProgress
	TaskFileNotExist
)

the enum of TaskStatus

func (TaskStatus) String

func (ts TaskStatus) String() string

convert task status to a string

Jump to

Keyboard shortcuts

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