cron

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateInput

type CreateInput struct {
	Name              string
	Prompt            string
	Schedule          string
	Enabled           bool
	HasEnable         bool
	SessionTarget     string
	ProjectID         string
	WakeMode          string
	DeliveryMode      string
	Payload           json.RawMessage
	DeleteAfterRun    bool
	HasDeleteAfterRun bool
}

type Job

type Job struct {
	ID                  string          `json:"id"`
	Name                string          `json:"name"`
	Prompt              string          `json:"prompt"`
	Schedule            string          `json:"schedule"`
	Enabled             bool            `json:"enabled"`
	SessionTarget       string          `json:"session_target,omitempty"`
	ProjectID           string          `json:"project_id,omitempty"`
	WakeMode            string          `json:"wake_mode,omitempty"`
	DeliveryMode        string          `json:"delivery_mode,omitempty"`
	Payload             json.RawMessage `json:"payload,omitempty"`
	DeleteAfterRun      bool            `json:"delete_after_run,omitempty"`
	LastRunAt           *time.Time      `json:"last_run_at,omitempty"`
	LastRunError        string          `json:"last_run_error,omitempty"`
	ConsecutiveFailures int             `json:"consecutive_failures,omitempty"`
	BackoffUntil        *time.Time      `json:"backoff_until,omitempty"`
	CreatedAt           time.Time       `json:"created_at"`
	UpdatedAt           time.Time       `json:"updated_at"`
}

type Manager

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

func NewManager

func NewManager(
	store *Store,
	runJob func(ctx context.Context, job Job) (string, error),
	interval time.Duration,
	nowFn func() time.Time,
) *Manager

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

func (*Manager) Tick

func (m *Manager) Tick(ctx context.Context) error

type RunRecord

type RunRecord struct {
	JobID    string    `json:"job_id"`
	RanAt    time.Time `json:"ran_at"`
	Response string    `json:"response,omitempty"`
	Error    string    `json:"error,omitempty"`
	Created  time.Time `json:"created_at"`
}

type Store

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

func NewStore

func NewStore(workspaceDir string) *Store

func NewStoreWithOptions

func NewStoreWithOptions(workspaceDir string, opts StoreOptions) *Store

func (*Store) Create

func (s *Store) Create(name, prompt string) (Job, error)

func (*Store) CreateWithOptions

func (s *Store) CreateWithOptions(input CreateInput) (Job, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) FinishRun

func (s *Store) FinishRun(id string)

func (*Store) Get

func (s *Store) Get(id string) (Job, error)

func (*Store) List

func (s *Store) List() ([]Job, error)

func (*Store) ListRuns

func (s *Store) ListRuns(id string, limit int) ([]RunRecord, error)

func (*Store) MarkRunResult

func (s *Store) MarkRunResult(id string, ranAt time.Time, response string, runErr error) (Job, error)

func (*Store) RunHistoryLimit

func (s *Store) RunHistoryLimit() int

func (*Store) TryStartRun

func (s *Store) TryStartRun(id string) bool

func (*Store) Update

func (s *Store) Update(id string, input UpdateInput) (Job, error)

func (*Store) WorkspaceDir

func (s *Store) WorkspaceDir() string

type StoreOptions

type StoreOptions struct {
	RunHistoryLimit int
}

type UpdateInput

type UpdateInput struct {
	Name           *string
	Prompt         *string
	Schedule       *string
	Enabled        *bool
	SessionTarget  *string
	ProjectID      *string
	WakeMode       *string
	DeliveryMode   *string
	Payload        *json.RawMessage
	DeleteAfterRun *bool
}

Jump to

Keyboard shortcuts

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