A Go library that delivers background jobs to Clerk's Jack service. It provides a pluggable Driver interface so that different job-sourcing strategies (Postgres WAL, polling, message queues, etc.) can be implemented independently.
┌──────────────────────────────────────────────────────┐
│ courier (this library) │
│ │
│ ┌────────┐ submit([]Job) ┌───────────────┐ │
│ │ Driver │ ──────────────────► │ gRPC client │ │
│ │ .Run()│ ◄────────────────── │ (EnqueueBulk) │ │
│ └────────┘ []SubmitResult └───────────────┘ │
│ ▲ │ │
│ │ ctx cancel │ │
│ │ (SIGINT/SIGTERM) ▼ │
│ ┌──────────────┐ ┌─────────────────┐ │
│ │ Health HTTP │ │ jack-service │ │
│ │ GET /health │ │ (gRPC server) │ │
│ └──────────────┘ └─────────────────┘ │
└──────────────────────────────────────────────────────┘
A Driver is the only thing you need to implement to create a new courier service. The interface is intentionally minimal:
Drivers are registered globally before calling Main:
func main() {
courier.RegisterDriver(myDriver)
courier.Main()
}JACK_COURIER_SUBMIT_TIMEOUT— per-call deadline applied to eachEnqueueBulkRPC, parsed as a Go duration (e.g.30s,1m). Defaults to30s. The driver's lifecycle context still controls overall shutdown; this only bounds an individual submit so a stalled jack-service cannot hang the courier.JACK_COURIER_SHUTDOWN_TIMEOUT— graceful shutdown timeout, parsed as a Go duration. Defaults to10s. OnSIGINT/SIGTERMthis bounds total termination time. If the driver does not return within it, the driver is abandoned and the process exits anyway, so the courier never takes longer than the timeout to shut down.