Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidJob is returned when a job fails validation. ErrInvalidJob = errors.New("invalid job") // ErrUnsupportedMethod is returned for unsupported HTTP methods. ErrUnsupportedMethod = errors.New("unsupported method") // ErrRetryableStatus marks responses that should be retried. ErrRetryableStatus = errors.New("retryable status") )
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback struct {
URL string
Method string
Headers map[string]string
Timeout time.Duration
MaxBodyBytes int
}
Callback describes where to send execution results.
type CallbackPayload ¶
type CallbackPayload struct {
JobID string `json:"job_id"`
ScheduledAt time.Time `json:"scheduled_at"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
Attempts int `json:"attempts"`
Success bool `json:"success"`
StatusCode int `json:"status_code,omitempty"`
Error string `json:"error,omitempty"`
ResponseBody string `json:"response_body,omitempty"`
}
CallbackPayload is posted to the callback endpoint after each execution.
type Job ¶
type Job struct {
ID string
Schedule Schedule
Request Request
Callback Callback
RetryPolicy RetryPolicy
}
Job defines the schedule and behavior for a task.
type Option ¶
type Option func(*Scheduler)
Option configures the scheduler.
func WithConcurrency ¶
WithConcurrency limits the number of concurrent executions.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client used for requests and callbacks.
func WithURLValidator ¶ added in v1.2.2
func WithURLValidator(validator *validate.URLValidator) Option
WithURLValidator sets the URL validator used for request and callback URLs. Pass nil to disable URL validation.
type Request ¶
type Request struct {
Method string
URL string
Headers map[string]string
Body []byte
Timeout time.Duration
}
Request describes the target HTTP request.
type RetryPolicy ¶
RetryPolicy defines how retries should be performed.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler coordinates scheduled jobs.
func NewScheduler ¶
NewScheduler creates a scheduler with the provided options.
type StatusError ¶
type StatusError struct {
StatusCode int
}
StatusError reports a non-successful response status.
func (*StatusError) Error ¶
func (e *StatusError) Error() string