Skip to content

Commit

Permalink
Fix lint. (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov authored Jun 10, 2024
1 parent 826a40a commit 662fdfb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 15 additions & 1 deletion pkg/messaging/pair/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,24 @@ func StartPairMessagingServer(
return err
}

loopErr := enterLoop(ctx, socket, logger, ns, es)
if loopErr != nil && !errors.Is(loopErr, context.Canceled) {
return loopErr
}
return nil
}

func enterLoop(
ctx context.Context,
socket protocol.Socket,
logger *zap.Logger,
ns nodes.Storage,
es *events.Storage,
) error {
for {
select {
case <-ctx.Done():
return nil
return ctx.Err()
default:
rawMsg, recvErr := socket.Recv()
if recvErr != nil {
Expand Down
9 changes: 6 additions & 3 deletions pkg/messaging/pubsub/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ func StartPubMessagingServer(
if err := socketPub.Listen(nanomsgURL); err != nil {
return err
}

return enterLoop(ctx, alerts, logger, socketPub)
loopErr := enterLoop(ctx, alerts, logger, socketPub)
if loopErr != nil && !errors.Is(loopErr, context.Canceled) {
return loopErr
}
return nil
}

func enterLoop(ctx context.Context, alerts <-chan entities.Alert, logger *zap.Logger, socketPub protocol.Socket) error {
for {
select {
case <-ctx.Done():
return nil
return ctx.Err()
case alert := <-alerts:
logger.Sugar().Infof("Alert has been generated: %v", alert)

Expand Down

0 comments on commit 662fdfb

Please sign in to comment.