Documentation
¶
Index ¶
- func ExpandTemplate(s string, t time.Time) string
- func FormatExample(t time.Time) string
- func SupportedPlaceholders() []string
- type Repository
- type Schedule
- type Scheduler
- type Server
- func (s *Server) CreateSchedule(ctx context.Context, req *connect.Request[taskguildv1.CreateScheduleRequest]) (*connect.Response[taskguildv1.CreateScheduleResponse], error)
- func (s *Server) DeleteSchedule(ctx context.Context, req *connect.Request[taskguildv1.DeleteScheduleRequest]) (*connect.Response[taskguildv1.DeleteScheduleResponse], error)
- func (s *Server) GetSchedule(ctx context.Context, req *connect.Request[taskguildv1.GetScheduleRequest]) (*connect.Response[taskguildv1.GetScheduleResponse], error)
- func (s *Server) ListSchedules(ctx context.Context, req *connect.Request[taskguildv1.ListSchedulesRequest]) (*connect.Response[taskguildv1.ListSchedulesResponse], error)
- func (s *Server) SetScheduleEnabled(ctx context.Context, ...) (*connect.Response[taskguildv1.SetScheduleEnabledResponse], error)
- func (s *Server) UpdateSchedule(ctx context.Context, req *connect.Request[taskguildv1.UpdateScheduleRequest]) (*connect.Response[taskguildv1.UpdateScheduleResponse], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpandTemplate ¶
ExpandTemplate replaces supported placeholders in s with the firing time t.
Supported placeholders:
{{date}} -> 2006-01-02
{{datetime}} -> 2006-01-02 15:04
{{year}} -> 2006
{{month}} -> 01
{{day}} -> 02
{{time}} -> 15:04
Unknown placeholders are left untouched.
func FormatExample ¶
FormatExample renders a sample of every placeholder for the given time. Used in tests and as documentation.
func SupportedPlaceholders ¶
func SupportedPlaceholders() []string
SupportedPlaceholders returns the list of supported placeholder tokens. Useful for surfacing to the UI as a hint.
Types ¶
type Repository ¶
type Repository interface {
Create(ctx context.Context, s *Schedule) error
Get(ctx context.Context, id string) (*Schedule, error)
List(ctx context.Context, projectID string, limit, offset int) ([]*Schedule, int, error)
// ListAll returns every schedule across all projects. Used by the scheduler
// at server startup to register all enabled schedules.
ListAll(ctx context.Context) ([]*Schedule, error)
Update(ctx context.Context, s *Schedule) error
Delete(ctx context.Context, id string) error
}
type Schedule ¶
type Schedule struct {
ID string `yaml:"id"`
ProjectID string `yaml:"project_id"`
WorkflowID string `yaml:"workflow_id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
CronExpression string `yaml:"cron_expression"`
Enabled bool `yaml:"enabled"`
// Task content (template fields expanded at fire time).
TaskTitle string `yaml:"task_title"`
TaskDescription string `yaml:"task_description"`
StatusID string `yaml:"status_id,omitempty"`
UseWorktree bool `yaml:"use_worktree"`
Effort string `yaml:"effort,omitempty"`
TaskMetadata map[string]string `yaml:"task_metadata,omitempty"`
// State updated by the scheduler.
LastRunAt time.Time `yaml:"last_run_at,omitempty"`
NextRunAt time.Time `yaml:"next_run_at,omitempty"`
LastError string `yaml:"last_error,omitempty"`
CreatedAt time.Time `yaml:"created_at"`
UpdatedAt time.Time `yaml:"updated_at"`
}
Schedule defines a cron-based recurring task creation.
type Scheduler ¶
type Scheduler interface {
// Add registers (or replaces) the schedule with the underlying cron runner.
// Must be safe to call concurrently. Implementations should be a no-op when
// the schedule is disabled, but it is the caller's responsibility to not
// register disabled schedules.
Add(s *Schedule) error
// Update is equivalent to Add for an already-registered schedule. It removes
// the existing entry then re-registers using the new cron expression.
Update(s *Schedule) error
// Remove unregisters the schedule. No-op if it was not registered.
Remove(id string)
// NextRun returns the next fire time for the given cron expression, or zero
// time if the expression is invalid.
NextRun(expr string, from time.Time) time.Time
}
Scheduler defines the behavior that schedule.Server requires from the in-process scheduler. The concrete implementation lives in internal/scheduler.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(repo Repository, workflowRepo workflow.Repository, sched Scheduler) *Server
func (*Server) CreateSchedule ¶
func (s *Server) CreateSchedule(ctx context.Context, req *connect.Request[taskguildv1.CreateScheduleRequest]) (*connect.Response[taskguildv1.CreateScheduleResponse], error)
func (*Server) DeleteSchedule ¶
func (s *Server) DeleteSchedule(ctx context.Context, req *connect.Request[taskguildv1.DeleteScheduleRequest]) (*connect.Response[taskguildv1.DeleteScheduleResponse], error)
func (*Server) GetSchedule ¶
func (s *Server) GetSchedule(ctx context.Context, req *connect.Request[taskguildv1.GetScheduleRequest]) (*connect.Response[taskguildv1.GetScheduleResponse], error)
func (*Server) ListSchedules ¶
func (s *Server) ListSchedules(ctx context.Context, req *connect.Request[taskguildv1.ListSchedulesRequest]) (*connect.Response[taskguildv1.ListSchedulesResponse], error)
func (*Server) SetScheduleEnabled ¶
func (s *Server) SetScheduleEnabled(ctx context.Context, req *connect.Request[taskguildv1.SetScheduleEnabledRequest]) (*connect.Response[taskguildv1.SetScheduleEnabledResponse], error)
func (*Server) UpdateSchedule ¶
func (s *Server) UpdateSchedule(ctx context.Context, req *connect.Request[taskguildv1.UpdateScheduleRequest]) (*connect.Response[taskguildv1.UpdateScheduleResponse], error)
Click to show internal directories.
Click to hide internal directories.