29 lines
477 B
Go
29 lines
477 B
Go
package bootstrap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
|
|
"iop/packages/go/config"
|
|
)
|
|
|
|
func Module(cfg *config.EdgeConfig) fx.Option {
|
|
return fx.Options(
|
|
fx.Provide(
|
|
func() *config.EdgeConfig { return cfg },
|
|
NewRuntime,
|
|
),
|
|
|
|
fx.Invoke(func(lc fx.Lifecycle, rt *Runtime) {
|
|
lc.Append(fx.Hook{
|
|
OnStart: func(ctx context.Context) error {
|
|
return rt.Start(ctx)
|
|
},
|
|
OnStop: func(_ context.Context) error {
|
|
return rt.Stop()
|
|
},
|
|
})
|
|
}),
|
|
)
|
|
}
|