Chrono|Docs

One-shot tasks

Schedule work once at a specific time

Schedule once

Use Schedule with WithTime when work should run once at a known time.

main.go
package main

import (
	"context"
	"time"

	"go.codnect.io/chrono"
)

func main() {
	scheduler := chrono.NewDefaultTaskScheduler()

	runAt := time.Now().Add(5 * time.Second)
	scheduler.Schedule(func(ctx context.Context) {
		println("send reminder")
	}, chrono.WithTime(runAt))

	<-scheduler.Shutdown()
}

One-shot schedules are useful for reminders, delayed actions, deadline checks, and deferred work that should not repeat.

Choose the start time

WithTime accepts a time.Time, so the schedule can be calculated from your own application data.

main.go
deadline := time.Date(2026, 8, 21, 10, 30, 0, 0, time.UTC)

scheduler.Schedule(func(ctx context.Context) {
	println("deadline reached")
}, chrono.WithTime(deadline))

Keep the calculation close to the business rule, then pass the final time to Chrono.