Skip to content

Commit

Permalink
fix(neuron): avoid flooding logs when disconnect (#3393)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyong Huang <[email protected]>
  • Loading branch information
ngjaying committed Nov 22, 2024
1 parent 3264042 commit 87ac981
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/io/neuron/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,21 @@ func (s *source) Subscribe(ctx api.StreamContext, ingest api.BytesIngest, ingest
ctx.GetLogger().Infof("neuron source receiving loop started")
go func() {
err := infra.SafeRun(func() error {
connected := true
for {
// no receiving deadline, will wait until the socket closed
if msg, err := s.cli.Recv(); err == nil {
connected = true
ctx.GetLogger().Debugf("nng received message %s", string(msg))
rawData, meta := extractTraceMeta(ctx, msg)
ingest(ctx, rawData, meta, timex.GetNow())
} else if err == mangos.ErrClosed {
ctx.GetLogger().Infof("neuron connection closed, retry after 1 second")
ingestErr(ctx, errors.New("neuron connection closed"))
time.Sleep(1 * time.Second)
if connected {
ctx.GetLogger().Infof("neuron connection closed, retry after 1 second")
ingestErr(ctx, errors.New("neuron connection closed"))
time.Sleep(1 * time.Second)
connected = false
}
continue
}
}
Expand Down

0 comments on commit 87ac981

Please sign in to comment.