@@ -26,7 +26,7 @@ const (
2626type ShardCreator struct {
2727 logger * zap.Logger
2828 timeSource clock.TimeSource
29- spectators map [ string ] spectatorclient.Spectator // namespace -> spectator
29+ spectators * spectatorclient.Spectators
3030 canaryClient sharddistributorv1.ShardDistributorExecutorCanaryAPIYARPCClient
3131 namespaces []string
3232
@@ -40,7 +40,7 @@ type ShardCreatorParams struct {
4040
4141 Logger * zap.Logger
4242 TimeSource clock.TimeSource
43- Spectators map [ string ] spectatorclient.Spectator
43+ Spectators * spectatorclient.Spectators
4444 CanaryClient sharddistributorv1.ShardDistributorExecutorCanaryAPIYARPCClient
4545}
4646
@@ -101,11 +101,12 @@ func (s *ShardCreator) process(ctx context.Context) {
101101 s .logger .Info ("Creating shard" , zap .String ("shardKey" , shardKey ), zap .String ("namespace" , namespace ))
102102
103103 // Get spectator for this namespace
104- spectator , ok := s .spectators [ namespace ]
105- if ! ok {
104+ spectator , err := s .spectators . ForNamespace ( namespace )
105+ if err != nil {
106106 s .logger .Warn ("No spectator for namespace, skipping shard creation" ,
107107 zap .String ("namespace" , namespace ),
108- zap .String ("shardKey" , shardKey ))
108+ zap .String ("shardKey" , shardKey ),
109+ zap .Error (err ))
109110 continue
110111 }
111112
0 commit comments