scheduler

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(sch schcli.Client, chat chatcli.Client) (schapi.Client, error)

New constructs a scheduler service requiring both a schedule store client and a chat client.

func NewFromEnv

func NewFromEnv(ctx context.Context) (schapi.Client, error)

NewFromEnv constructs a scheduler client using env-backed datly and wires an internal chat service instance for optional orchestration.

Types

type Service

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

Service implements client/scheduler.Client by delegating persistence to the schedule store and optionally enriching runs with a created conversation via chat when missing.

func (*Service) GetRuns

func (s *Service) GetRuns(ctx context.Context, scheduleID, since string, session ...codec.SessionOption) ([]*schapi.Run, error)

GetRuns lists runs for a schedule, optionally filtered by since id.

func (*Service) GetSchedule

func (s *Service) GetSchedule(ctx context.Context, id string, session ...codec.SessionOption) (*schapi.Schedule, error)

GetSchedule returns a schedule by id or nil if not found.

func (*Service) ListSchedules

func (s *Service) ListSchedules(ctx context.Context, session ...codec.SessionOption) ([]*schapi.Schedule, error)

ListSchedules returns all schedules.

func (*Service) Run

func (s *Service) Run(ctx context.Context, in *schapi.MutableRun) error

Run creates or updates a run, optionally creating a conversation using chat when ConversationId is missing.

func (*Service) RunDue

func (s *Service) RunDue(ctx context.Context) (int, error)

RunDue lists schedules, checks if due, and triggers runs while avoiding duplicates. Returns number of runs started.

func (*Service) Schedule

func (s *Service) Schedule(ctx context.Context, in *schapi.MutableSchedule) error

Schedule creates or updates a schedule (generic upsert via Has flags).

type Watchdog added in v0.2.2

type Watchdog struct {

	// Errors receives errors encountered during RunDue calls. It is buffered
	// and non-blocking; consumers may choose to drain it for diagnostics.
	Errors chan error
	// contains filtered or unexported fields
}

Watchdog encapsulates a background ticker that periodically invokes scheduler.Client.RunDue to trigger due runs. Call Stop to cancel.

func StartWatchdog added in v0.2.2

func StartWatchdog(parent context.Context, client schapi.Client, interval time.Duration) *Watchdog

StartWatchdog launches a background goroutine that calls RunDue on the provided scheduler client at the specified interval. If interval <= 0, a default of 30s is used. The returned Watchdog can be stopped via Stop().

func (*Watchdog) Stop added in v0.2.2

func (w *Watchdog) Stop()

Stop cancels the watchdog loop.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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