confxxl

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Code generated by genx:code@v0.3.0 DO NOT EDIT.

Index

Constants

View Source
const (
	PATH_EXECUTOR = "executor"
	PATH_ACTION   = "action"
)

these constants defines exposed api parameters key in path eg: /{host-unique-identifier}/{executor}/{action}

Variables

View Source
var (
	From  = contextx.From[tCtxRegistry, Registry]
	Must  = contextx.Must[tCtxRegistry, Registry]
	With  = contextx.With[tCtxRegistry, Registry]
	Carry = contextx.Carry[tCtxRegistry, Registry]
)

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	types.Endpoint[Option]
	// contains filtered or unexported fields
}

func (*Endpoint) Close

func (e *Endpoint) Close() error

func (*Endpoint) Init

func (e *Endpoint) Init(ctx context.Context) (err error)

func (*Endpoint) IsActive

func (e *Endpoint) IsActive(exec string) bool

func (*Endpoint) RegisterJob

func (e *Endpoint) RegisterJob(exec string, job string, fn JobHandler) error

func (*Endpoint) SetDefault

func (e *Endpoint) SetDefault()

type Error

type Error int8

Error presents error codes for confxxl +genx:code

const (
	ERROR_UNDEFINED Error = iota
	ERROR__XXL_INVALID_ACTION
	ERROR__ENDPOINT_CLOSED
	ERROR__EXECUTOR_CLOSED
	ERROR__EXECUTOR_NOT_REGISTERED
	ERROR__EXECUTOR_REGISTER_FAILED
	ERROR__EXECUTOR_REGISTER_REMOVE_FAILED
	ERROR__EXECUTOR_CALLBACK_FAILED
	ERROR__EXECUTOR_SCHEDULE_TIMEOUT
	ERROR__JOB_MANAGER_CLOSED
	ERROR__JOB_MANAGER_REGISTRY_CONFLICT
	ERROR__JOB_NOT_REGISTERED
	ERROR__JOB_SCHEDULER_BUSY
	ERROR__JOB_PENDING_TASK_SKIP
	ERROR__JOB_CLOSED       // job is closed
	ERROR__JOB_MANUAL_CLOSE // job is closed by user
)

func (Error) Message

func (e Error) Message() string

type Executor

type Executor interface {
	// Register registers a job of `name` with handler `j` to Executor
	Register(name string, j JobHandler) error
	// Kill kills a job by job id
	Kill(int64) error
	// Do execute schedule once with job `name` and trigger data `t`
	Do(t *TriggerRequest) error
	// Close closes executor
	Close() error
	// RefreshActivity refreshes last heartbeat request time from xxl-job
	RefreshActivity()
	// IsActive reports if this Executor is enabled in xxl-job service
	IsActive() bool
	// IsIdle check idle status by job ID.
	IsIdle(int64) bool
}

func NewExecutor

func NewExecutor(ctx context.Context, executorName, remoteAddr, listenAddr string, appliers ...ExecutorOptionApplier) (Executor, error)

type ExecutorOption

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

type ExecutorOptionApplier

type ExecutorOptionApplier func(*ExecutorOption)

func WithAccessToken

func WithAccessToken(token string) ExecutorOptionApplier

func WithHttpClient

func WithHttpClient(client *http.Client) ExecutorOptionApplier

func WithKeepAliveInterval

func WithKeepAliveInterval(keepalive time.Duration) ExecutorOptionApplier

func WithLogger

func WithLogger(logger logx.Logger) ExecutorOptionApplier

func WithMaxBacklogs

func WithMaxBacklogs(backlogs int) ExecutorOptionApplier

type IdleBeatRequest

type IdleBeatRequest struct {
	JobID int64 `json:"jobID"`
}

type JobCallback

type JobCallback func(*TriggerRequest, error)

type JobHandler

type JobHandler func(context.Context, *TriggerRequest) error

type JobManager

type JobManager interface {
	// Register registers a job with name, job handler h and option appliers.
	// It starts scheduler of this job.
	Register(name string, h JobHandler, appliers ...JobOptionApplier) error
	// Unregister unregisters job by name and releases scheduler.
	Unregister(name string) error
	// Schedule does once schedule.
	// The result can be retrieved by JobCallback, if it is configurated when Register
	Schedule(context.Context, string, *TriggerRequest) error
	// IsIdle return if job is during scheduling
	IsIdle(name string) bool
	// Close closes all registered Scheduler.
	Close() error
}

type JobOption

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

type JobOptionApplier

type JobOptionApplier func(*JobOption)

func WithCallback

func WithCallback(cb JobCallback) JobOptionApplier

func WithMaxPending

func WithMaxPending(n int) JobOptionApplier

type KillJobRequest

type KillJobRequest struct {
	JobID int64 `json:"jobID"`
}

type Option

type Option struct {
	ClientID string
	// Listener denotes local exposed address. this address reports to xxl-job
	// service for accepting trigger request from xxl-job
	Listener string `url:""`
	// AccessToken xxl-job request access token
	AccessToken string `url:""`
	// KeepAlive heartbeat interval for executors
	KeepAlive types.Duration `url:",default=30s"`
	// ClientTimeout heartbeat interval for executors
	ClientTimeout types.Duration `url:",default=5s"`
	// DisableDebugLog if disable debug log
	DisableDebugLog bool `url:",default=false"`
	// MaxBacklogs denotes max backlogs per job. if job trigger parameter use
	// enums.BLOCK_STRATEGY__SERIAL_EXECUTION mode it may cause backlogs.
	// when backlogs reached this limitation the trigger will be callback with
	// ERROR__JOB_REACH_MAX_BACKLOG error
	MaxBacklogs int `url:",default=10"`
	// Executor registered executor list
	Executor []string
}

func (*Option) SetDefault

func (o *Option) SetDefault()

type Registry

type Registry interface {
	Close() error

	RegisterJob(executor string, job string, fn JobHandler) error
	IsActive(executor string) bool
}

type Task

type Task interface {
	// Name denotes Task name
	Name() string
	// Close stops job scheduling
	Close() error
	// Push appends a task for scheduling
	Push(context.Context, *TriggerRequest) error
	// Pending returns pending task count
	Pending() int
	// Scheduling returns scheduling task count
	Scheduling() int
	// SkipPreviousAndPush appending task after skip previous tasks
	SkipPreviousAndPush(ctx context.Context, r *TriggerRequest) error
	// PushIfIdle appending task if current scheduler is idle
	PushIfIdle(ctx context.Context, r *TriggerRequest) error
}

type TriggerRequest

type TriggerRequest struct {
	// JobID 任务ID
	JobID int64 `json:"jobId"`
	// ExecutorHandler 任务标识
	ExecutorHandler string `json:"executorHandler"`
	// ExecutorParams 任务参数
	ExecutorParams string `json:"executorParams"`
	// ExecutorBlockStrategy 任务阻塞策略
	ExecutorBlockStrategy enums.BlockStrategy `json:"executorBlockStrategy"`
	// ExecutorTimeout 任务超时时间(秒,大于零生效)
	ExecutorTimeout int64 `json:"executorTimeout"`
	// LogID 本次调度日志ID
	LogID int64 `json:"logId"`
	// LogDateTime 本次调度日志时间
	LogDateTime int64 `json:"logDateTime"`
	// GlueType 任务模式
	GlueType enums.GlueType `json:"glueType"`
	// GlueSource GLUE脚本代码
	GlueSource string `json:"glueSource"`
	// GlueUpdateTime GLUE脚本更新时间,用于判定脚本是否变更以及是否需要刷新
	GlueUpdateTime int64 `json:"glueUpdatetime"`
	// BroadcastIndex 当前分片
	BroadcastIndex int64 `json:"broadcastIndex"`
	// BroadcastTotal 总分片
	BroadcastTotal int64 `json:"broadcastTotal"`
}

Directories

Path Synopsis
Code generated by genx:enum@v0.3.0 DO NOT EDIT.
Code generated by genx:enum@v0.3.0 DO NOT EDIT.

Jump to

Keyboard shortcuts

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