cron

package
v0.0.0-...-1746241 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 18 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Cron Service

Responsibility

Dynamic cron CRUD, scheduler runtime, webhook execution and execution analytics.

Structure

  • service.go — cron use-cases: create/update/delete/list/test/clone.
  • config.go — cron defaults and config helpers.
  • apis/ — project API routes under /crons.
  • forms/ — reserved for submit-flow/form objects.
  • models/ — Cron and CronExecution persistence models.
  • queries/ — reserved for read-side/query helpers.
  • migrations/ — cron-owned DB schema updates.
  • runtime.go — logger/runtime helpers.
  • scheduler.go / execution.go — mutable scheduler and execution runtime.
  • store.go — DAO helpers used by service/runtime.

Dependencies

  • core.App
  • tools/cron
  • services/cron/models

Public flows

  • Create/update cron jobs.
  • Schedule, pause/resume and execute jobs.
  • Persist execution history.
  • Expose stats/metrics endpoints for cron executions.

Migration notes

Cron owns the cron_executions table and schema completion for the legacy crons table. The older combined crons + newsletter_settings migration remains in migrations/dbase for history; new cron-owned changes live in services/cron/migrations and are registered via migrations/dbase/cron_module.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Status  int    `json:"-"`
	Err     error  `json:"-"`
}

func (*APIError) Error

func (e *APIError) Error() string

type Config

type Config struct {
	Enabled bool
}

func DefaultConfig

func DefaultConfig() Config

type CreateCronData

type CreateCronData struct {
	Name                string                 `json:"name"`
	Description         string                 `json:"description"`
	Schedule            string                 `json:"schedule"`
	WebhookURL          string                 `json:"webhook_url"`
	WebhookMethod       string                 `json:"webhook_method"`
	WebhookHeaders      map[string]interface{} `json:"webhook_headers"`
	WebhookPayload      map[string]interface{} `json:"webhook_payload"`
	TimeoutSeconds      int                    `json:"timeout_seconds"`
	NotifyOnSuccess     bool                   `json:"notify_on_success"`
	NotifyOnFailure     bool                   `json:"notify_on_failure"`
	NotificationWebhook string                 `json:"notification_webhook"`
	MaxRetries          int                    `json:"max_retries"`
	RetryDelaySeconds   int                    `json:"retry_delay_seconds"`
}

type CronService

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

func NewCronService

func NewCronService(scheduler *Scheduler, executor *Executor) *CronService

func (*CronService) CloneCron

func (s *CronService) CloneCron(cronId string, userId string, newName string) (*cronmodels.Cron, error)

func (*CronService) CreateCron

func (s *CronService) CreateCron(userId string, data CreateCronData) (*cronmodels.Cron, error)

func (*CronService) CreateSystemCron

func (s *CronService) CreateSystemCron(systemType string, config CreateCronData) (*cronmodels.Cron, error)

func (*CronService) DeleteCron

func (s *CronService) DeleteCron(cronId string, userId string) error

func (*CronService) DeleteSystemCron

func (s *CronService) DeleteSystemCron(systemType string) error

func (*CronService) GetCron

func (s *CronService) GetCron(cronId string, userId string) (*cronmodels.Cron, error)

func (*CronService) GetSystemCron

func (s *CronService) GetSystemCron(systemType string) (*cronmodels.Cron, error)

func (*CronService) ListCrons

func (s *CronService) ListCrons(userId string, filters map[string]interface{}) ([]*cronmodels.Cron, error)

func (*CronService) PauseCron

func (s *CronService) PauseCron(cronId string, userId string) error

func (*CronService) ResumeCron

func (s *CronService) ResumeCron(cronId string, userId string) error

func (*CronService) TestCron

func (s *CronService) TestCron(cronId string, userId string) error

func (*CronService) UpdateCron

func (s *CronService) UpdateCron(cronId string, userId string, data UpdateCronData) (*cronmodels.Cron, error)

type ExecutionResult

type ExecutionResult struct {
	Status          string
	HTTPStatus      int
	DurationMs      int64
	RequestURL      string
	RequestMethod   string
	RequestHeaders  map[string]string
	RequestPayload  map[string]interface{}
	ResponseHeaders map[string]string
	ResponseBody    string
	ErrorMessage    string
	ErrorStack      string
	StartedAt       time.Time
	CompletedAt     time.Time
	RetryCount      int
}

type Executor

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

func NewExecutor

func NewExecutor() *Executor

func NewExecutorWithApp

func NewExecutorWithApp(app core.App) *Executor

func (*Executor) Execute

func (e *Executor) Execute(cronRecord *cronmodels.Cron) error

type Scheduler

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

func NewScheduler

func NewScheduler(executor *Executor) *Scheduler

func (*Scheduler) AddCron

func (s *Scheduler) AddCron(cronRecord *cronmodels.Cron) error

func (*Scheduler) ExecuteCron

func (s *Scheduler) ExecuteCron(cronId string) error

func (*Scheduler) ReloadCrons

func (s *Scheduler) ReloadCrons() error

func (*Scheduler) RemoveCron

func (s *Scheduler) RemoveCron(cronId string) error

func (*Scheduler) Start

func (s *Scheduler) Start() error

func (*Scheduler) Stop

func (s *Scheduler) Stop()

type UpdateCronData

type UpdateCronData struct {
	Name                *string                `json:"name"`
	Description         *string                `json:"description"`
	Schedule            *string                `json:"schedule"`
	WebhookURL          *string                `json:"webhook_url"`
	WebhookMethod       *string                `json:"webhook_method"`
	WebhookHeaders      map[string]interface{} `json:"webhook_headers"`
	WebhookPayload      map[string]interface{} `json:"webhook_payload"`
	TimeoutSeconds      *int                   `json:"timeout_seconds"`
	IsActive            *bool                  `json:"is_active"`
	NotifyOnSuccess     *bool                  `json:"notify_on_success"`
	NotifyOnFailure     *bool                  `json:"notify_on_failure"`
	NotificationWebhook *string                `json:"notification_webhook"`
	MaxRetries          *int                   `json:"max_retries"`
	RetryDelaySeconds   *int                   `json:"retry_delay_seconds"`
}

Directories

Path Synopsis
Package migrations owns cron service storage migrations.
Package migrations owns cron service storage migrations.

Jump to

Keyboard shortcuts

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