fix: add LifecyclesParams struct

This commit is contained in:
Derrick Hammer 2024-01-28 04:45:34 -05:00
parent 568ec2857a
commit 18a54917a0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 8 additions and 2 deletions

View File

@ -31,9 +31,15 @@ func BuildApis(config *viper.Viper) fx.Option {
return fx.Options(options...) return fx.Options(options...)
} }
func SetupLifecycles(lifecycle fx.Lifecycle, protocols []registry.API) { type LifecyclesParams struct {
fx.In
Protocols []registry.API `group:"protocol"`
}
func SetupLifecycles(lifecycle fx.Lifecycle, params LifecyclesParams) {
for _, entry := range registry.GetRegistry() { for _, entry := range registry.GetRegistry() {
for _, protocol := range protocols { for _, protocol := range params.Protocols {
if protocol.Name() == entry.Key { if protocol.Name() == entry.Key {
lifecycle.Append(fx.Hook{ lifecycle.Append(fx.Hook{
OnStart: func(ctx context.Context) error { OnStart: func(ctx context.Context) error {