Documentation
¶
Index ¶
- type AgentPayload
- type GormJobStore
- func (s *GormJobStore) Delete(ctx context.Context, id string) error
- func (s *GormJobStore) Get(ctx context.Context, id string) (*Job, error)
- func (s *GormJobStore) GetPendingJobs(ctx context.Context) ([]*Job, error)
- func (s *GormJobStore) List(ctx context.Context, offset, limit int) ([]*Job, int64, error)
- func (s *GormJobStore) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
- func (s *GormJobStore) ResetStuckJobs(ctx context.Context, timeout time.Duration) error
- func (s *GormJobStore) Save(ctx context.Context, job *Job) error
- func (s *GormJobStore) UpdateStatus(ctx context.Context, id string, status JobStatus, lastRun *time.Time, ...) error
- type Job
- type JobPayload
- type JobStatus
- type JobStore
- type JobType
- type ListOptions
- type Locker
- type MemoryJobStore
- func (s *MemoryJobStore) Delete(ctx context.Context, id string) error
- func (s *MemoryJobStore) Get(ctx context.Context, id string) (*Job, error)
- func (s *MemoryJobStore) GetPendingJobs(ctx context.Context) ([]*Job, error)
- func (s *MemoryJobStore) List(ctx context.Context, offset, limit int) ([]*Job, int64, error)
- func (s *MemoryJobStore) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
- func (s *MemoryJobStore) ResetStuckJobs(ctx context.Context, timeout time.Duration) error
- func (s *MemoryJobStore) Save(ctx context.Context, job *Job) error
- func (s *MemoryJobStore) UpdateStatus(ctx context.Context, id string, status JobStatus, lastRun *time.Time, ...) error
- type MetricsRecorder
- type OneShotSchedule
- type Scheduler
- func (s *Scheduler) AddJob(ctx context.Context, name string, jobType JobType, schedule string, ...) (string, error)
- func (s *Scheduler) AddJobWithOptions(ctx context.Context, name string, jobType JobType, schedule string, ...) (string, error)
- func (s *Scheduler) ListJobs(ctx context.Context, offset, limit int) ([]*Job, int64, error)
- func (s *Scheduler) ListJobsWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
- func (s *Scheduler) RegisterHandler(taskType TaskType, handler TaskHandler)
- func (s *Scheduler) RemoveJob(ctx context.Context, id string) error
- func (s *Scheduler) SetFailureHandler(h func(job *Job, err error))
- func (s *Scheduler) SetLocker(l Locker)
- func (s *Scheduler) SetMaxConcurrent(n int)
- func (s *Scheduler) SetMetricsRecorder(rec MetricsRecorder)
- func (s *Scheduler) SetStuckCheck(interval, timeout time.Duration)
- func (s *Scheduler) Start()
- func (s *Scheduler) Stop()
- func (s *Scheduler) StopJob(ctx context.Context, id string) error
- type SystemPayload
- type TaskHandler
- type TaskType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentPayload ¶
type AgentPayload struct {
Message string `json:"message"`
Model string `json:"model,omitempty"`
Thinking string `json:"thinking,omitempty"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
MaxIterations int `json:"max_iterations,omitempty"`
Tools []string `json:"tools,omitempty"`
Skills []string `json:"skills,omitempty"`
}
AgentPayload defines the structure for agent-driven tasks
type GormJobStore ¶
type GormJobStore struct {
// contains filtered or unexported fields
}
func NewGormJobStore ¶
func NewGormJobStore(db *gorm.DB) *GormJobStore
func (*GormJobStore) GetPendingJobs ¶
func (s *GormJobStore) GetPendingJobs(ctx context.Context) ([]*Job, error)
func (*GormJobStore) ListWithOptions ¶ added in v1.7.0
func (s *GormJobStore) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
func (*GormJobStore) ResetStuckJobs ¶
type Job ¶
type Job struct {
ID string `gorm:"primaryKey" json:"id"`
Name string `json:"name"`
Type JobType `json:"type"`
SessionID string `json:"session_id" gorm:"index"`
Schedule string `json:"schedule"` // Cron expr, duration string, or timestamp
Status JobStatus `json:"status"`
Payload string `json:"payload"` // JSON encoded data
TaskType TaskType `json:"task_type"`
Retries int `json:"retries"`
MaxRetries int `json:"max_retries"`
LastRunAt *time.Time `json:"last_run_at"`
NextRunAt time.Time `json:"next_run_at" gorm:"index"`
// Execution stats
RunningAt *time.Time `json:"running_at,omitempty"`
LastDuration time.Duration `json:"last_duration,omitempty"`
LastError string `json:"last_error,omitempty"`
Enabled bool `json:"enabled" gorm:"default:true"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
CronEntryID int `gorm:"-" json:"-"` // Internal cron entry ID
ExecutionMode string `json:"execution_mode" gorm:"column:execution_mode;default:''"`
}
Job represents a scheduled task
type JobPayload ¶
type JobPayload struct {
TargetID string `json:"target_id"` // UserID or AgentID
Data map[string]string `json:"data"`
}
JobPayload is the generic structure for job data
type JobStore ¶
type JobStore interface {
Save(ctx context.Context, job *Job) error
Get(ctx context.Context, id string) (*Job, error)
Delete(ctx context.Context, id string) error
List(ctx context.Context, offset, limit int) ([]*Job, int64, error)
ListWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
GetPendingJobs(ctx context.Context) ([]*Job, error)
UpdateStatus(ctx context.Context, id string, status JobStatus, lastRun *time.Time, nextRun time.Time, lastDuration time.Duration, lastError string) error
ResetStuckJobs(ctx context.Context, timeout time.Duration) error
}
type ListOptions ¶ added in v1.7.0
type MemoryJobStore ¶ added in v1.6.13
type MemoryJobStore struct {
// contains filtered or unexported fields
}
MemoryJobStore implements JobStore using in-memory map
func NewMemoryJobStore ¶ added in v1.6.13
func NewMemoryJobStore() *MemoryJobStore
NewMemoryJobStore creates a new in-memory job store
func (*MemoryJobStore) Delete ¶ added in v1.6.13
func (s *MemoryJobStore) Delete(ctx context.Context, id string) error
func (*MemoryJobStore) GetPendingJobs ¶ added in v1.6.13
func (s *MemoryJobStore) GetPendingJobs(ctx context.Context) ([]*Job, error)
func (*MemoryJobStore) ListWithOptions ¶ added in v1.7.0
func (s *MemoryJobStore) ListWithOptions(ctx context.Context, opts ListOptions) ([]*Job, int64, error)
func (*MemoryJobStore) ResetStuckJobs ¶ added in v1.6.13
type MetricsRecorder ¶ added in v1.7.0
type MetricsRecorder interface {
JobStarted(jobID, taskType string)
JobCompleted(jobID, taskType string, duration time.Duration)
JobFailed(jobID, taskType string)
}
MetricsRecorder is an optional observer for job execution (e.g. Prometheus/OTel).
type OneShotSchedule ¶
Custom Schedule for OneShot
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) AddJobWithOptions ¶ added in v1.7.0
func (*Scheduler) ListJobsWithOptions ¶ added in v1.7.0
func (*Scheduler) RegisterHandler ¶
func (s *Scheduler) RegisterHandler(taskType TaskType, handler TaskHandler)
func (*Scheduler) SetFailureHandler ¶
func (*Scheduler) SetMaxConcurrent ¶ added in v1.7.0
func (*Scheduler) SetMetricsRecorder ¶ added in v1.7.0
func (s *Scheduler) SetMetricsRecorder(rec MetricsRecorder)
func (*Scheduler) SetStuckCheck ¶ added in v1.7.0
type SystemPayload ¶
SystemPayload defines the structure for system events
Click to show internal directories.
Click to hide internal directories.