cron

package
v0.31.117 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergePayloadMeta added in v0.24.0

func MergePayloadMeta(raw json.RawMessage, meta PayloadMeta) (json.RawMessage, error)

Types

type CreateInput

type CreateInput struct {
	Name              string
	Prompt            string
	Schedule          string
	Enabled           bool
	HasEnable         bool
	SessionID         string
	SessionTarget     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"`
	SessionID           string          `json:"session_id,omitempty"`
	SessionTarget       string          `json:"session_target,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 PayloadMeta added in v0.24.0

type PayloadMeta struct {
	TaskType          string `json:"task_type,omitempty"`
	ReminderMessage   string `json:"reminder_message,omitempty"`
	SourceSessionKind string `json:"source_session_kind,omitempty"`
	TelegramChatID    string `json:"telegram_chat_id,omitempty"`
	TelegramThreadID  string `json:"telegram_thread_id,omitempty"`
	TelegramBotID     string `json:"telegram_bot_id,omitempty"`
}

func ExtractPayloadMeta added in v0.24.0

func ExtractPayloadMeta(raw json.RawMessage) (PayloadMeta, bool)

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
	SessionID      *string
	SessionTarget  *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