Files
go-omni/examples/program/internal/run/run.go

20 lines
571 B
Go

package run
import (
"context"
"example.com/program/internal/svc"
)
// Run is project-owned. Return nil for normal completion, or an error to fail.
// The starter waits for shutdown; a one-shot program can simply return when done.
// Register background stop/drain hooks in svc.Init, not concurrently here.
// Accepted background work uses deps.WorkContext(), not the early-stop ctx.
func Run(ctx context.Context, deps *svc.ServiceContext) error {
if deps.Config.Once {
deps.Logger.InfoContext(ctx, "program.completed")
return nil
}
<-ctx.Done()
return nil
}