Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPRunner ¶
type HTTPRunner struct {
// contains filtered or unexported fields
}
HTTPRunner wraps an *http.Server as a Runner. The caller is responsible for configuring the server (timeouts, handler, TLS).
func NewHTTPRunner ¶
NewHTTPRunner creates a plain HTTP runner.
func NewHTTPSRunner ¶
func NewHTTPSRunner(name string, server *http.Server, certFile, keyFile string, log *slog.Logger) *HTTPRunner
NewHTTPSRunner creates a TLS HTTP runner.
func (*HTTPRunner) Name ¶
func (r *HTTPRunner) Name() string
type JobFn ¶
JobFn is a periodic task. Errors are logged and the scheduler continues. To stop on error, return a wrapped sentinel and check it in an outer WorkerRunner.
type SchedulerRunner ¶
type SchedulerRunner struct {
// contains filtered or unexported fields
}
SchedulerRunner executes a JobFn on a fixed interval using time.Ticker. Missed ticks (slow jobs) are dropped — no queue buildup.
func NewSchedulerRunner ¶
func (*SchedulerRunner) Name ¶
func (r *SchedulerRunner) Name() string
type WorkFn ¶
WorkFn is the unit of work executed each iteration. Return an error to trigger the onError callback. Return ctx.Err() (or nil) to stop cleanly.
type WorkerOption ¶
type WorkerOption func(*WorkerRunner)
func WithErrorHandler ¶
func WithErrorHandler(fn func(err error)) WorkerOption
WithErrorHandler overrides the default log-and-continue error handler. To make errors fatal (stop the worker), call the provided cancel func.
type WorkerRunner ¶
type WorkerRunner struct {
// contains filtered or unexported fields
}
WorkerRunner executes a WorkFn in a tight loop until ctx is cancelled. It does NOT restart after failure — if you need retry, implement it inside WorkFn.
func NewWorkerRunner ¶
func NewWorkerRunner(name string, fn WorkFn, log *slog.Logger, opts ...WorkerOption) *WorkerRunner
func (*WorkerRunner) Name ¶
func (r *WorkerRunner) Name() string