Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventTrigger ¶
type EventTrigger struct {
Trigger chan bool // Channel to signal an event.
}
EventTrigger triggers based on an external event signaled through a channel.
func (*EventTrigger) IsReady ¶
func (t *EventTrigger) IsReady() bool
IsReady checks if there is a signal in the trigger channel.
func (*EventTrigger) Reset ¶
func (t *EventTrigger) Reset()
Reset for EventTrigger does nothing as its state is managed externally.
type Execution ¶
type Execution struct { StartedAt time.Time // Start time of the execution. EndedAt time.Time // End time of the execution. Status string // Status of the execution (e.g., "SUCCESS", "FAILED"). Error string // Error message if the execution failed. Event interface{} // Event associated with the execution. Results interface{} // Results of the execution. }
Execution records the execution details of a task.
type OneTimeTrigger ¶
type OneTimeTrigger struct { Delay time.Duration // The delay after which to trigger. // contains filtered or unexported fields }
OneTimeTrigger triggers once after a specified delay.
func (*OneTimeTrigger) IsReady ¶
func (t *OneTimeTrigger) IsReady() bool
IsReady checks if the current time has passed the delay period.
func (*OneTimeTrigger) Reset ¶
func (t *OneTimeTrigger) Reset()
Reset sets the trigger registration time to the current time.
type PeriodicTrigger ¶
type PeriodicTrigger struct { Interval time.Duration // Interval for periodic triggering. CronExpr string // Cron expression for triggering. // contains filtered or unexported fields }
PeriodicTrigger triggers at regular intervals or based on a cron expression.
func (*PeriodicTrigger) IsReady ¶
func (t *PeriodicTrigger) IsReady() bool
IsReady checks if the trigger should activate based on time or cron expression.
func (*PeriodicTrigger) Reset ¶
func (t *PeriodicTrigger) Reset()
Reset updates the last triggered time to the current time.
type RetryPolicy ¶
type RetryPolicy struct { MaxRetries int // Maximum number of retries. Delay time.Duration // Delay between retries. }
RetryPolicy defines the policy for retrying tasks on failure.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler orchestrates the execution of tasks based on their triggers and priority.
func NewScheduler ¶
NewScheduler creates a new Scheduler with a specified limit on running tasks.
func (*Scheduler) RemoveTask ¶
RemoveTask removes a task from the scheduler.
type Task ¶
type Task struct { ID int // Unique identifier for the task. Name string // Name of the task. Description string // Description of the task. Triggers []Trigger // List of triggers for the task. Function func(args interface{}) error // Function to execute as the task. Args []interface{} // Arguments for the task function. RetryPolicy RetryPolicy // Retry policy for the task. Enabled bool // Flag indicating if the task is enabled. Priority int // Priority of the task for scheduling. ExecutionHist []Execution // History of task executions. }
Task represents a schedulable task.