feat: release v0.28 generic Go project scaffolding and lifecycle entry
This commit is contained in:
19
examples/program/internal/run/run.go
Normal file
19
examples/program/internal/run/run.go
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user