Files
go-omni/examples/managedService/internal/svc/serviceContext.go

27 lines
866 B
Go

package svc
import (
"context"
"example.com/managed/internal/config"
"git.yuntuo.hk/k2safe/go-omni/health"
"git.yuntuo.hk/k2safe/go-omni/httpx"
"git.yuntuo.hk/k2safe/go-omni/lifecycle"
"git.yuntuo.hk/k2safe/go-omni/logx"
)
// Context holds project dependencies. Runtime owns cleanup and shutdown.
// Logger is borrowed; the generated entry closes it after dependencies.
type ServiceContext struct {
*lifecycle.Runtime
Config config.Config
Logger *logx.Logger
Health *health.Checker
Middlewares map[string]httpx.Middleware
}
// Init is project-owned. Add dependencies here and immediately register each
// cleanup with c.OnClose. Returning an error automatically rolls everything back.
// Generated infrastructure is ready here. Never create another App or logger.
func (c *ServiceContext) Init(ctx context.Context) error { return nil }