Documentation ¶
Index ¶
- Constants
- Variables
- func InitExecute() (err error)
- type BuiltInExecutor
- func (b *BuiltInExecutor) AddScheduledTask(cron string, r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
- func (b *BuiltInExecutor) AddTask(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
- func (b *BuiltInExecutor) CheckAction(r rule.Rule) ([]string, error)
- func (b *BuiltInExecutor) Clean() error
- func (b *BuiltInExecutor) Execute(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
- func (b *BuiltInExecutor) GetTask(id string) *Task
- func (b *BuiltInExecutor) RemoveTask(taskID string) error
- func (b *BuiltInExecutor) Start() error
- func (b *BuiltInExecutor) Stop() error
- type CallbackFunc
- type ErrNotAction
- type Executor
- type ExecutorConfig
- type Task
- type TaskStatus
- type TaskType
Constants ¶
View Source
const ( TaskStatus_OK = "ok" TaskStatus_Wait = "wait" TaskStatus_Fail = "fail" TaskStatus_Run = "run" )
View Source
const ( TaskType_Once = "once" TaskType_Cycle = "cycle" )
Variables ¶
View Source
var DefaultExecutorConfig = ExecutorConfig{ Ctx: context.TODO(), MaxPoolSize: int64(runtime.NumCPU()), AutoCleanInterval: 0, AutoCleanRuleQuantity: 0, }
Functions ¶
func InitExecute ¶
func InitExecute() (err error)
Types ¶
type BuiltInExecutor ¶
type BuiltInExecutor struct {
// contains filtered or unexported fields
}
func NewBuiltInExecutor ¶
func NewBuiltInExecutor(configs ...ExecutorConfig) (*BuiltInExecutor, error)
func (*BuiltInExecutor) AddScheduledTask ¶
func (b *BuiltInExecutor) AddScheduledTask(cron string, r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
func (*BuiltInExecutor) AddTask ¶
func (b *BuiltInExecutor) AddTask(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
func (*BuiltInExecutor) CheckAction ¶
func (b *BuiltInExecutor) CheckAction(r rule.Rule) ([]string, error)
func (*BuiltInExecutor) Clean ¶
func (b *BuiltInExecutor) Clean() error
func (*BuiltInExecutor) Execute ¶
func (b *BuiltInExecutor) Execute(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error)
func (*BuiltInExecutor) GetTask ¶
func (b *BuiltInExecutor) GetTask(id string) *Task
func (*BuiltInExecutor) RemoveTask ¶
func (b *BuiltInExecutor) RemoveTask(taskID string) error
func (*BuiltInExecutor) Start ¶
func (b *BuiltInExecutor) Start() error
func (*BuiltInExecutor) Stop ¶
func (b *BuiltInExecutor) Stop() error
type CallbackFunc ¶
type ErrNotAction ¶
type ErrNotAction struct {
// contains filtered or unexported fields
}
func (ErrNotAction) Error ¶
func (e ErrNotAction) Error() string
type Executor ¶
type Executor interface { // Start the executor Start() error // Stop the executor Stop() error // CheckAction It is used to check whether the rule can be executed. //The []string of the return value informs the caller that it cannot be executed due to the lack of dependent actions. //The error is a running error. A simple lack of dependencies will not report an error. CheckAction(r rule.Rule) ([]string, error) // Execute A separate thread will immediately execute the rule without queuing for the thread pool to become free // Returns the ID of the executed rule and execution error Execute(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error) // Add will add the rule to the execution queue for execution // Returns the ID of the executed rule and execution error AddTask(r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error) // AddScheduledRule A timed rule will be added, and the timed rule will never be automatically recycled // Returns the ID of the executed rule and execution error AddScheduledTask(cron string, r rule.Rule, params map[string]interface{}, callback CallbackFunc) (string, error) // RemoveRule will stop the corresponding Task execution plan based on the rule id and remove the rule from itself RemoveTask(taskID string) error // Clean will immediately clean up the garbage // The garbage includes rules that have been executed // But does not include rules that are not executed, rules that are being executed, and rules that are executed regularly Clean() error // GetRule will get the rule object saved by itself according to the rule id GetTask(id string) *Task }
Executor is used to execute the rule, it should not be one-off, and it should be idempotent every time the rule is executed
func GetExecutor ¶
func GetExecutor() Executor
type ExecutorConfig ¶
type ExecutorConfig struct { // Ctx is the context that may be passed to the executor Ctx context.Context // MaxPoolSize unlimited by default MaxPoolSize int64 // AutoCleanRuleQuantity in second, unlimited by default AutoCleanInterval int64 // AutoCleanRuleQuantity unlimited by default AutoCleanRuleQuantity int64 }
ExecutorConfig is Executor's config
func (*ExecutorConfig) Update ¶
func (e *ExecutorConfig) Update(config ...ExecutorConfig)
type TaskStatus ¶
type TaskStatus string
Click to show internal directories.
Click to hide internal directories.