Skip to content

Commit 150093f

Browse files
committed
Small fix to the initializaiton
Signed-off-by: Jakob Haahr Taankvist <jht@uber.com>
1 parent 843f27a commit 150093f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

service/sharddistributor/canary/module.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package canary
22

33
import (
4-
"context"
5-
64
"go.uber.org/fx"
75
"go.uber.org/yarpc"
86

@@ -84,13 +82,11 @@ func opts(names NamespacesNames) fx.Option {
8482
)),
8583
fx.Provide(sharddistributorv1.NewFxShardDistributorExecutorCanaryAPIYARPCProcedures()),
8684

87-
fx.Invoke(func(lc fx.Lifecycle, chooser spectatorclient.SpectatorPeerChooserInterface, spectators *spectatorclient.Spectators) {
88-
lc.Append(fx.Hook{
89-
OnStart: func(ctx context.Context) error {
90-
chooser.SetSpectators(spectators)
91-
return nil
92-
},
93-
})
85+
// There is a circular dependency between the spectator client and the peer chooser, since
86+
// the yarpc dispatcher needs the peer chooser and the peer chooser needs the spectators, which needs the yarpc dispatcher.
87+
// To break the circular dependency, we set the spectators on the peer chooser here.
88+
fx.Invoke(func(chooser spectatorclient.SpectatorPeerChooserInterface, spectators *spectatorclient.Spectators) {
89+
chooser.SetSpectators(spectators)
9490
}),
9591
)
9692
}

0 commit comments

Comments
 (0)