fix: add LifecyclesParams struct
This commit is contained in:
parent
610d5fe268
commit
568ec2857a
|
@ -31,9 +31,15 @@ func BuildProtocols(config *viper.Viper) fx.Option {
|
||||||
return fx.Options(options...)
|
return fx.Options(options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupLifecycles(lifecycle fx.Lifecycle, protocols []registry.Protocol) {
|
type LifecyclesParams struct {
|
||||||
|
fx.In
|
||||||
|
|
||||||
|
Protocols []registry.Protocol `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 {
|
||||||
|
|
Loading…
Reference in New Issue