Skip to content

Commit

Permalink
fix: prevent network without a receiver erroring (#680)
Browse files Browse the repository at this point in the history
  • Loading branch information
robdefeo committed Feb 18, 2021
1 parent 1abeac5 commit a0e4c86
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/mailchain/internal/fetching/fetching.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@ func getReceivers(config *settings.Root) (receiverByKind map[string]mailbox.Rece
}

for p := range config.Protocols {
logger := log.With().Str("component", "Fetching").Str("protocol", p).Logger()
protocol := config.Protocols[p]

if protocol.Disabled.Get() {
logger.Info().Msg("protocol disabled skipping")
continue
}

for n := range protocol.Networks {
logger := logger.With().Str("network", n).Logger()
network := protocol.Networks[n]

if network.Disabled() {
logger.Info().Msg("network disabled skipping")
continue
}

Expand All @@ -43,6 +49,11 @@ func getReceivers(config *settings.Root) (receiverByKind map[string]mailbox.Rece
return nil, nil, nil, errors.WithMessagef(err, "failed to get receiver for %s.%s", p, n)
}

if r == nil {
logger.Info().Msg("no receiver configured skipping")
continue
}

receiverByKind[r.Kind()] = r
kindProtocolsNetworks[r.Kind()] = appendListMap(kindProtocolsNetworks, r.Kind(), p+"."+n)

Expand Down

0 comments on commit a0e4c86

Please sign in to comment.