rpc

package
v0.0.0-...-281483f Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const HttpExecTimeout = 300

http任务执行时间不超过300秒

Variables

View Source
var (
	EtcdAddr = flag.String("EtcdAddr", "127.0.0.1:2379", "register etcd address")
)
View Source
var (
	ServiceName = flag.String("ServiceName", "task", "service name")
)

Functions

func AssembleCmd

func AssembleCmd(cron *gocron.TaskRequest) string

命令组装

func GetLogFile

func GetLogFile(Jobid int64, Taskid int64) string

获取日志文件

func SendNotification

func SendNotification(jobModel model.VCron, taskResult model.TaskResult)

发送任务结果通知

Types

type CronClient

type CronClient struct{}

RPC调用执行任务

func (*CronClient) Run

func (c *CronClient) Run(Job model.VCron, TaskId int64, ExpireTime int64) model.TaskResult

type CronResponse

type CronResponse struct {
	Host   string
	Code   int64
	Result string
	Err    error
}

type MyServer

type MyServer struct{}

func (*MyServer) AfterExecJob

func (s *MyServer) AfterExecJob(queryResult CronResponse, req *gocron.TaskRequest)

执行完后更新日志

func (*MyServer) BeforeExecJob

func (s *MyServer) BeforeExecJob(TaskId int64)

开始执行任务

func (*MyServer) Run

服务入口

func (*MyServer) Start

func (s *MyServer) Start()

type ResponseWrapper

type ResponseWrapper struct {
	StatusCode int
	Body       string
	Header     http.Header
}

type RpcServiceCurl

type RpcServiceCurl struct {
	Result string
	Err    error
}

func (*RpcServiceCurl) ExecCurl

func (h *RpcServiceCurl) ExecCurl(ctx context.Context, command string) CronResponse

func (*RpcServiceCurl) Get

func (h *RpcServiceCurl) Get(url string, timeout int) ResponseWrapper

func (*RpcServiceCurl) PostParams

func (h *RpcServiceCurl) PostParams(url string, params string, timeout int) ResponseWrapper

func (*RpcServiceCurl) Request

func (h *RpcServiceCurl) Request(req *http.Request, timeout int) ResponseWrapper

type RpcServiceShell

type RpcServiceShell struct {
	Result string
	Err    error
}

func (*RpcServiceShell) ExecShell

func (c *RpcServiceShell) ExecShell(ctx context.Context, command string, taskid int64) CronResponse

执行shell命令,可设置执行超时时间

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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