fix(monitor/collectors/coinbase): exhaustive switches, %w double-wrap, require.ErrorIs (lint)
This commit is contained in:
parent
d352a6bce6
commit
2ccc379255
|
|
@ -153,7 +153,7 @@ func (c *Conn) ReadFrame(ctx context.Context) (Frame, error) {
|
|||
func decodeFrame(msg []byte) (Frame, error) {
|
||||
var env rawEnvelope
|
||||
if err := json.Unmarshal(msg, &env); err != nil {
|
||||
return Frame{}, fmt.Errorf("%w: %v", ErrFrameMalformed, err)
|
||||
return Frame{}, fmt.Errorf("%w: %w", ErrFrameMalformed, err)
|
||||
}
|
||||
|
||||
frame := Frame{
|
||||
|
|
|
|||
|
|
@ -102,6 +102,8 @@ func (c *Collector) handleConn(ctx context.Context, conn *Conn) error {
|
|||
|
||||
loopErr := ReadLoop(ctx, conn, seq, func(hctx context.Context, f Frame) error {
|
||||
switch f.Kind {
|
||||
case FrameTypeUnknown, FrameTypeSubscriptions, FrameTypeHeartbeats:
|
||||
return nil
|
||||
case FrameTypeTicker, FrameTypeSnapshot:
|
||||
ts := f.Timestamp.UTC()
|
||||
if ts.IsZero() {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func ReadLoop(ctx context.Context, conn *Conn, seq *Sequencer, handler FrameHand
|
|||
}
|
||||
|
||||
switch frame.Kind {
|
||||
case FrameTypeUnknown, FrameTypeSubscriptions, FrameTypeHeartbeats:
|
||||
case FrameTypeSnapshot:
|
||||
seq.Reset()
|
||||
for _, t := range frame.Tickers {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ package coinbase_test
|
|||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -144,5 +143,5 @@ func TestRepo_LatestTickMissingReturnsErrNoRows(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
|
||||
_, err := repo.LatestTick(ctx, "DOES-NOT-EXIST")
|
||||
require.True(t, errors.Is(err, sql.ErrNoRows))
|
||||
require.ErrorIs(t, err, sql.ErrNoRows)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue