Documentation
¶
Index ¶
Constants ¶
const ( DefaultRetryAttempts = 0 DefaultRestartOnError = false )
Variables ¶
This section is empty.
Functions ¶
func Err ¶ added in v1.1.5
Err wraps err with a stack trace captured at the call site. Use it inside a cron job to get traces that reach the failure site:
func myJob() error {
if err := doWork(); err != nil {
return cron.Err(err)
}
return nil
}
Without Err(), the cron runner can only capture the stack trace of the goroutine that called the job, which is not very useful for debugging.
Types ¶
type Config ¶
type Config struct {
// When set to true the server will attempt to restart failed jobs
RestartOnError bool
// The number of times a job will be retried before it is deleted
// when an error occurs
//
// Default: 0
RetryAttempts int
// This is the periodic time in which the server can execute
// background tasks background tasks can run infinitely
// as long as the server is running
// for example you can use this to make requests to other servers
// or update your database
//
// Default: 5 minutes
BackgroundTimeout time.Duration
}
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
func (*Cron) Start ¶
func (c *Cron) Start()
Call this method to start the cron
By default cron jobs are executed in their own goroutines. This method starts the cron jobs in a new goroutine away from the server's main goroutine.
This ensures non blocking execution of cron jobs hence the server can handle requests as cron jobs are executed with minimal impact on the server
type Job ¶
This is the structure of a background job you can use this to put whatever jobs you want to perform in the background as the server runs and Pine will take care of executing them in the background
time is optional and defaults to 5 minutes according to the server configuration
Fn is the function that will be executed. It should always return an error. If error is not nil the error will be used to delete the task from the queue otherwise when nil the task will run indefinitely
type JobError ¶ added in v1.1.5
type JobError struct {
// contains filtered or unexported fields
}
JobError is an error that carries a stack trace captured at the point the error was created — inside the job function, before it returned. Construct one with Err() so the cron runner can report the full trace.