Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action = middleware.Handler[Context]
type Middleware ¶
type Middleware = middleware.Middleware[Context]
func Logging ¶
func Logging(logger *slog.Logger) Middleware
Logging creates a middleware that adds detailed logging.
func Metrics ¶
func Metrics() Middleware
Metrics creates a middleware that collects job execution metrics.
func Recovery ¶
func Recovery(logger *slog.Logger, stack bool) Middleware
Recovery creates a middleware that recovers from panics.
func Timeout ¶
func Timeout(timeout time.Duration) Middleware
Timeout creates a middleware that adds a timeout to job execution.
func Trace ¶
func Trace(tracerName string) Middleware
Trace creates a middleware that adds OpenTelemetry tracing.
type Option ¶
type Option func(s *Server)
Option is the new server option.
func WithCronOptions ¶
WithCronOptions sets the cron options.
func WithMiddlewares ¶
func WithMiddlewares(mws ...Middleware) Option
WithMiddlewares adds middleware to the cron server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a cron server which implements kraots [transport.Server].
func (*Server) Start ¶
Start starts the cron scheduler. It will run all registered jobs according to their schedule. This method is a blocking call and will not return until the scheduler is stopped.
func (*Server) Stop ¶
Stop stops the cron scheduler. It waits for all running jobs to finish before returning. If a job is running long, it will return an error. This is a blocking call.
If you want to stop the cron server without waiting for jobs to finish, you can use a separate context with a timeout or cancellation. This will stop the cron server immediately without waiting for jobs to finish.