Engineering note · 2026-08-23
A small Go worker for Quill Cloud
This tutorial shows a complete handler shape for a Go worker. The example validates input, returns transient errors only when appropriate, and logs the task identifier.
package main
import (
"context"
"errors"
"log"
"time"
)
type Task struct { ID string; Payload map[string]string }
func handle(ctx context.Context, task Task) error {
if task.Payload["recipient"] == "" { return errors.New("recipient is required") }
select { case <-ctx.Done(): return ctx.Err(); case <-time.After(25 * time.Millisecond): }
log.Printf("completed task %s", task.ID)
return nil
}
func main() {
task := Task{ID: "task_demo", Payload: map[string]string{"recipient": "dev@example.test"}}
if err := handle(context.Background(), task); err != nil { log.Fatal(err) }
}