scheduler

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoalControllerSchedule added in v0.1.13

type GoalControllerSchedule struct {
	Mode    string
	Preview *string
	WakeAt  *time.Time
}

type Handler

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

Handler serves scheduler HTTP endpoints.

func NewHandler

func NewHandler(svc *Service) *Handler

NewHandler creates a scheduler HTTP handler.

func (*Handler) Register

func (h *Handler) Register(mux *http.ServeMux)

Register mounts all scheduler routes on the given mux.

func (*Handler) RegisterWithoutRunNow

func (h *Handler) RegisterWithoutRunNow(mux *http.ServeMux)

RegisterWithoutRunNow mounts scheduler routes except the run-now endpoint.

type Option

type Option func(*Service)

Option customizes the scheduler service.

func WithAuthConfig added in v0.1.1

func WithAuthConfig(cfg *svcauth.Config) Option

WithAuthConfig sets auth configuration used by scheduler OOB user_cred flow.

func WithConversationClient

func WithConversationClient(client convcli.Client) Option

WithConversationClient sets the conversation client used to annotate scheduled conversations.

func WithInterval

func WithInterval(d time.Duration) Option

WithInterval sets the watchdog polling interval.

func WithMaxConcurrentRuns added in v0.1.8

func WithMaxConcurrentRuns(n int) Option

WithMaxConcurrentRuns caps the number of in-flight executeRun goroutines. A value <= 0 disables the cap (unbounded fan-out) and matches historical behaviour. When the cap is reached, new enqueueAndLaunch calls block until an existing run finishes.

func WithScyService

func WithScyService(sv *scy.Service) Option

WithScyService sets the scy service for loading encrypted secrets.

func WithTokenProvider

func WithTokenProvider(p token.Provider) Option

WithTokenProvider sets the token provider for credential management.

func WithUserCredAuthConfig added in v0.1.2

func WithUserCredAuthConfig(cfg *UserCredAuthConfig) Option

WithUserCredAuthConfig sets public scheduler auth configuration used by legacy user_cred_url OOB authorization.

func WithUserService added in v0.1.7

func WithUserService(users svcauth.UserService) Option

WithUserService sets the user service used to resolve scheduler subjects to persistent user IDs for the created_by_user_id auth path.

type RunListPage added in v0.1.1

type RunListPage struct {
	Rows       []*schrun.RunView
	PageCount  int
	TotalCount int
}

type Schedule

type Schedule struct {
	ID              string     `json:"id"`
	Name            string     `json:"name"`
	Description     *string    `json:"description,omitempty"`
	CreatedByUserID *string    `json:"createdByUserId,omitempty"`
	Visibility      string     `json:"visibility,omitempty"`
	Internal        bool       `json:"internal,omitempty"`
	ConversationID  *string    `json:"conversationId,omitempty"`
	GoalID          *string    `json:"goalId,omitempty"`
	AgentRef        string     `json:"agentRef"`
	ModelOverride   *string    `json:"modelOverride,omitempty"`
	UserCredURL     *string    `json:"userCredUrl,omitempty"`
	Enabled         bool       `json:"enabled"`
	StartAt         *time.Time `json:"startAt,omitempty"`
	EndAt           *time.Time `json:"endAt,omitempty"`
	ScheduleType    string     `json:"scheduleType"`
	CronExpr        *string    `json:"cronExpr,omitempty"`
	IntervalSeconds *int       `json:"intervalSeconds,omitempty"`
	Timezone        string     `json:"timezone,omitempty"`
	TimeoutSeconds  int        `json:"timeoutSeconds,omitempty"`
	TaskPromptURI   *string    `json:"taskPromptUri,omitempty"`
	TaskPrompt      *string    `json:"taskPrompt,omitempty"`
	NextRunAt       *time.Time `json:"nextRunAt,omitempty"`
	LastRunAt       *time.Time `json:"lastRunAt,omitempty"`
	LastStatus      *string    `json:"lastStatus,omitempty"`
	LastError       *string    `json:"lastError,omitempty"`
	LeaseOwner      *string    `json:"leaseOwner,omitempty"`
	LeaseUntil      *time.Time `json:"leaseUntil,omitempty"`
	CreatedAt       time.Time  `json:"createdAt"`
	UpdatedAt       *time.Time `json:"updatedAt,omitempty"`
}

Schedule represents a scheduled task configuration.

type ScheduleStore

type ScheduleStore = Store

ScheduleStore is kept as a compatibility alias for the persisted scheduler store.

type Service

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

Service manages persisted scheduler CRUD and execution of due schedules.

func New

func New(store Store, agent *agentsvc.Service, opts ...Option) *Service

New creates a scheduler service.

func (*Service) CancelGoalWakeups added in v0.1.13

func (s *Service) CancelGoalWakeups(ctx context.Context, conversationID, goalID string) error

func (*Service) CurrentGoalWakeup added in v0.1.13

func (s *Service) CurrentGoalWakeup(ctx context.Context, conversationID, goalID string) *GoalControllerSchedule

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

Delete removes a schedule when the caller owns it.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*Schedule, error)

Get returns a schedule by ID.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]*Schedule, error)

List returns schedules visible to the caller.

func (*Service) RunDue

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

RunDue scans persisted schedules, claims due slots, and starts runs.

func (*Service) RunNow

func (s *Service) RunNow(ctx context.Context, id string) error

RunNow enqueues and starts an immediate execution for a schedule.

func (*Service) ScheduleGoalWakeup added in v0.1.13

func (s *Service) ScheduleGoalWakeup(ctx context.Context, req agentsvc.GoalWakeupRequest) (bool, error)

func (*Service) StartWatchdog

func (s *Service) StartWatchdog(ctx context.Context)

StartWatchdog begins a background loop that polls for due schedules at the configured interval. It blocks until ctx is cancelled.

func (*Service) Upsert

func (s *Service) Upsert(ctx context.Context, schedule *Schedule) error

Upsert creates or updates a schedule using marker-based partial updates.

type Store

type Store interface {
	Get(ctx context.Context, id string) (*schedulepkg.ScheduleView, error)
	List(ctx context.Context) ([]*schedulepkg.ScheduleView, error)
	ListRuns(ctx context.Context, in *schrun.RunListInput, page, size int) (*RunListPage, error)
	ListForRunDue(ctx context.Context) ([]*schedulepkg.ScheduleView, error)
	DeleteSchedule(ctx context.Context, id string) error
	PatchSchedule(ctx context.Context, schedule *schedwrite.Schedule) error
	PatchRuns(ctx context.Context, rows []*agrunwrite.MutableRunView) error
	ListRunsForDue(ctx context.Context, scheduleID string, scheduledFor *time.Time, excludeStatuses []string) ([]*schrun.RunView, error)
	TryClaimSchedule(ctx context.Context, scheduleID, leaseOwner string, leaseUntil time.Time) (bool, error)
	ReleaseScheduleLease(ctx context.Context, scheduleID, leaseOwner string) (bool, error)
	TryClaimRun(ctx context.Context, runID, leaseOwner string, leaseUntil time.Time) (bool, error)
	ReleaseRunLease(ctx context.Context, runID, leaseOwner string) (bool, error)
}

Store provides persisted scheduler reads/writes backed by Datly components.

func NewDatlyStore

func NewDatlyStore(ctx context.Context, dao *datly.Service, dataSvc data.Service) (Store, error)

type UserCredAuthConfig added in v0.1.2

type UserCredAuthConfig struct {
	Mode            string
	ClientConfigURL string
	Scopes          []string
}

UserCredAuthConfig contains the subset of auth settings required for legacy scheduler user_cred_url OOB authorization.

Jump to

Keyboard shortcuts

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