Documentation
¶
Index ¶
- Variables
- type DefaultExecutorFactory
- type ExecutionResult
- type Executor
- type ExecutorFactory
- type FunctionExecutor
- func (f *FunctionExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
- func (f *FunctionExecutor) HasFunction(name string) bool
- func (f *FunctionExecutor) ListFunctions() []string
- func (f *FunctionExecutor) RegisterFunction(name string, ...)
- func (f *FunctionExecutor) Type() domain.TaskType
- func (f *FunctionExecutor) Validate(ctx context.Context, job domain.CronJob) error
- type GRPCExecutor
- type GRPCTaskConfig
- type HTTPExecutor
- type HTTPTaskConfig
- type HistoryRecordingExecutor
- type RetryableExecutor
- type RetryableHistoryExecutor
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type DefaultExecutorFactory ¶
type DefaultExecutorFactory struct {
// contains filtered or unexported fields
}
DefaultExecutorFactory 默认执行器工厂
func (*DefaultExecutorFactory) GetExecutor ¶
func (f *DefaultExecutorFactory) GetExecutor(taskType domain.TaskType) (Executor, error)
GetExecutor 获取执行器
func (*DefaultExecutorFactory) RegisterExecutor ¶
func (f *DefaultExecutorFactory) RegisterExecutor(executor Executor)
RegisterExecutor 注册执行器
func (*DefaultExecutorFactory) ValidateTask ¶
ValidateTask 校验任务配置
type ExecutionResult ¶
type ExecutionResult struct {
Success bool `json:"success"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
Duration int64 `json:"duration"` // 毫秒
}
ExecutionResult 任务执行结果
type Executor ¶
type Executor interface {
// Execute 执行任务
Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
// Validate 校验任务配置是否有效(创建任务时调用)
Validate(ctx context.Context, job domain.CronJob) error
// Type 返回执行器类型
Type() domain.TaskType
}
Executor 任务执行器接口
type ExecutorFactory ¶
type ExecutorFactory interface {
// GetExecutor 根据任务类型获取执行器
GetExecutor(taskType domain.TaskType) (Executor, error)
// ValidateTask 校验任务配置是否有效
ValidateTask(ctx context.Context, job domain.CronJob) error
}
ExecutorFactory 执行器工厂
func NewExecutorFactory ¶
func NewExecutorFactory(l logx.Loggerx) ExecutorFactory
NewExecutorFactory 创建执行器工厂
func NewExecutorFactoryWithHistory ¶
func NewExecutorFactoryWithHistory(historyService service.JobHistoryService, l logx.Loggerx) ExecutorFactory
NewExecutorFactoryWithHistory 创建带历史记录的执行器工厂
type FunctionExecutor ¶
type FunctionExecutor struct {
// contains filtered or unexported fields
}
FunctionExecutor Function类型任务执行器
func NewFunctionExecutor ¶
func NewFunctionExecutor(l logx.Loggerx) *FunctionExecutor
NewFunctionExecutor 创建Function执行器
func (*FunctionExecutor) Execute ¶
func (f *FunctionExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行Function任务
func (*FunctionExecutor) HasFunction ¶
func (f *FunctionExecutor) HasFunction(name string) bool
HasFunction 检查函数是否已注册
func (*FunctionExecutor) ListFunctions ¶
func (f *FunctionExecutor) ListFunctions() []string
ListFunctions 列出所有已注册的函数名
func (*FunctionExecutor) RegisterFunction ¶
func (f *FunctionExecutor) RegisterFunction(name string, fn func(context.Context, map[string]interface{}) (interface{}, error))
RegisterFunction 注册函数
type GRPCExecutor ¶
type GRPCExecutor struct {
// contains filtered or unexported fields
}
GRPCExecutor gRPC任务执行器
func (*GRPCExecutor) Execute ¶
func (g *GRPCExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行gRPC任务
type GRPCTaskConfig ¶
type GRPCTaskConfig struct {
Target string `json:"target"` // gRPC服务地址,如 "localhost:50051"
Service string `json:"service"` // 服务名,如 "helloworld.Greeter"
Method string `json:"method"` // 方法名,如 "SayHello"
RequestData string `json:"request_data"` // 请求数据(JSON格式)
Metadata map[string]string `json:"metadata"` // gRPC元数据
}
GRPCTaskConfig gRPC任务配置
type HTTPExecutor ¶
type HTTPExecutor struct {
// contains filtered or unexported fields
}
HTTPExecutor HTTP任务执行器
func (*HTTPExecutor) Execute ¶
func (h *HTTPExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行HTTP任务
type HTTPTaskConfig ¶
type HTTPTaskConfig struct {
URL string `json:"url"`
Method string `json:"method"` // GET, POST, PUT, DELETE
Headers map[string]string `json:"headers"`
Body string `json:"body"`
}
HTTPTaskConfig HTTP任务配置(存储在CronJob的额外字段中)
type HistoryRecordingExecutor ¶
type HistoryRecordingExecutor struct {
// contains filtered or unexported fields
}
HistoryRecordingExecutor 带历史记录功能的执行器包装器
func NewHistoryRecordingExecutor ¶
func NewHistoryRecordingExecutor(executor Executor, historyService service.JobHistoryService, l logx.Loggerx) *HistoryRecordingExecutor
NewHistoryRecordingExecutor 创建带历史记录的执行器
func (*HistoryRecordingExecutor) Execute ¶
func (h *HistoryRecordingExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行任务并记录历史
func (*HistoryRecordingExecutor) Type ¶
func (h *HistoryRecordingExecutor) Type() domain.TaskType
Type 返回执行器类型
type RetryableExecutor ¶
type RetryableExecutor struct {
// contains filtered or unexported fields
}
RetryableExecutor 带重试机制的执行器包装器
func NewRetryableExecutor ¶
func NewRetryableExecutor(executor Executor, l logx.Loggerx) *RetryableExecutor
NewRetryableExecutor 创建带重试的执行器
func (*RetryableExecutor) Execute ¶
func (r *RetryableExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行任务(带重试)
type RetryableHistoryExecutor ¶
type RetryableHistoryExecutor struct {
// contains filtered or unexported fields
}
RetryableHistoryExecutor 带重试和历史记录的执行器包装器
func NewRetryableHistoryExecutor ¶
func NewRetryableHistoryExecutor(executor Executor, historyService service.JobHistoryService, l logx.Loggerx) *RetryableHistoryExecutor
NewRetryableHistoryExecutor 创建带重试和历史记录的执行器
func (*RetryableHistoryExecutor) Execute ¶
func (r *RetryableHistoryExecutor) Execute(ctx context.Context, job domain.CronJob) (*ExecutionResult, error)
Execute 执行任务(带重试和历史记录)
func (*RetryableHistoryExecutor) Type ¶
func (r *RetryableHistoryExecutor) Type() domain.TaskType
Type 返回执行器类型