22 lines
913 B
Cheetah
22 lines
913 B
Cheetah
package svc
|
|
import (
|
|
"context"
|
|
"git.yuntuo.hk/k2safe/go-omni/lifecycle"
|
|
"git.yuntuo.hk/k2safe/go-omni/logx"
|
|
"PROJECT_MODULE/internal/config"
|
|
)
|
|
// ServiceContext is project-owned. Add dependencies without global variables.
|
|
// Runtime owns registered resources; Logger is borrowed from the entry point.
|
|
type ServiceContext struct {
|
|
*lifecycle.Runtime
|
|
Config config.Config
|
|
Logger *logx.Logger
|
|
}
|
|
// Init runs before Run. Register resources immediately with OnClose.
|
|
// Register paired OnStop/OnDrain hooks before exposing background work.
|
|
// Use WorkContext for accepted work; Context is the early stop notification.
|
|
// OnDrain returns nil only after processing and final cleanup have completed.
|
|
// Complete all registrations here, before Run can race with shutdown.
|
|
// The drain name "go-omni/project/run" is reserved for the generated entry.
|
|
func(c *ServiceContext)Init(ctx context.Context)error{return nil}
|