job

package
v0.0.0-...-e9de818 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HttpMethodGet  = "GET"
	HttpMethodPost = "POST"
)
View Source
const (
	FinishFlag = "FINISH"

	JobInfo  = "JobInfo:%s"
	JobStat  = "JobStat:%s"
	JobResp  = "JobResp:%s"
	JobRetry = "JobRetry:%s"
)

Variables

View Source
var (
	AJF    *apiJobFunc
	ApiMap map[string]map[string]interface{}
)
View Source
var (
	JM *jobManager
	CM *cronJobManager
)
View Source
var (
	LocalHost string
)

Functions

func AgentHBRlt

func AgentHBRlt(jid string, v interface{}) (interface{}, error)

func AgentListRlt

func AgentListRlt(jid string, v interface{}) (interface{}, error)

func DistributeJob

func DistributeJob(jobId string, k, v interface{})

func Finish

func Finish(jobId string)

func GetResult

func GetResult(jobId string) []string

func GetStat

func GetStat(jobId string) map[string]interface{}

func InitApiMap

func InitApiMap()

func NewApiJobFunc

func NewApiJobFunc() *apiJobFunc

func NewCronJob

func NewCronJob(name string, conNum int, timeout int) (string, error)

func NewCronJobManager

func NewCronJobManager() *cronJobManager

func NewJob

func NewJob(name string, conNum int, timeout int, needRes bool) (string, error)

func NewJobManager

func NewJobManager() *jobManager

func StopJob

func StopJob(jobId string)

func SyncRecv

func SyncRecv(transInfo TransInfo)

Types

type ApiJob

type ApiJob struct {
	SimpleJob
}

type DisJob

type DisJob func(jid string, k, v interface{}) (interface{}, error)

type DoJob

type DoJob func(jid string, args interface{}) (interface{}, error)

type DoRlt

type DoRlt func(jid string, res interface{}) (interface{}, error)

type FinishSyncInfo

type FinishSyncInfo struct {
	Id string `json:"id"`
}

type Job

type Job interface {
	GetId() string
	Run(chan bool)
	Distribute(jid string, k, v interface{}) error
	Retry()
	RltCallback(jid string, v interface{}) (interface{}, error)
	Finish()
	Stop()
}

func NewApiJob

func NewApiJob(id string, name string, conNum int, timeout int, needRes bool, rds redis.UniversalClient) Job

type JobArgs

type JobArgs struct {
	Name    string      `json:"name"`
	Host    string      `json:"host"`
	Path    string      `json:"path"`
	Args    interface{} `json:"args"`
	Scheme  string      `json:"scheme"`
	Method  string      `json:"method"`
	Timeout int         `json:"timeout"`
}

type JobResWithArgs

type JobResWithArgs struct {
	Args     *JobArgs
	Response *grequests.Response
	Result   string
}

type NewSyncInfo

type NewSyncInfo struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	ConNum  int    `json:"con_num"`
	Timeout int    `json:"timeout"`
	NeedRes bool   `json:"need_res"`
}

type SimpleJob

type SimpleJob struct {
	Id      string
	Name    string
	Mode    int
	Meta    map[string]interface{}
	Workers []string
	ConNum  int
	Timeout int
	NeedRes bool //whether save the result to redis
	//stop job channel
	Done chan bool
	//
	Dis DisJob
	Do  DoJob
	Rlt DoRlt

	Rds redis.UniversalClient
}

func NewSimpleJob

func NewSimpleJob(id string, name string, mode int, meta map[string]interface{}, workers []string, conNum int, timeout int, needRes bool, dis DisJob, do DoJob, rlt DoRlt, rds redis.UniversalClient) SimpleJob

func (*SimpleJob) Distribute

func (sj *SimpleJob) Distribute(jid string, k, v interface{}) error

func (*SimpleJob) Finish

func (sj *SimpleJob) Finish()

func (*SimpleJob) GetId

func (sj *SimpleJob) GetId() string

func (*SimpleJob) Retry

func (sj *SimpleJob) Retry()

func (*SimpleJob) RltCallback

func (sj *SimpleJob) RltCallback(k string, v interface{}) (interface{}, error)

func (*SimpleJob) Run

func (sj *SimpleJob) Run(over chan bool)

func (*SimpleJob) Stop

func (sj *SimpleJob) Stop()

type StopSyncInfo

type StopSyncInfo struct {
	Id string `json:"id"`
}

type TransInfo

type TransInfo struct {
	Action string `json:"action"`
	Data   string `json:"data"`
}

Jump to

Keyboard shortcuts

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