From d7b4b160f2033a2acbfa4960e2a43423fdd21069 Mon Sep 17 00:00:00 2001 From: Trim21 Date: Tue, 15 Oct 2024 06:39:12 +0800 Subject: [PATCH] chore: add more logging --- canal/on_subject.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/canal/on_subject.go b/canal/on_subject.go index c60a4287..0cc87d0a 100644 --- a/canal/on_subject.go +++ b/canal/on_subject.go @@ -19,6 +19,7 @@ import ( "encoding/json" "github.com/trim21/errgo" + "go.uber.org/zap" "github.com/bangumi/server/internal/model" ) @@ -26,7 +27,7 @@ import ( func (e *eventHandler) OnSubject(ctx context.Context, key json.RawMessage, payload Payload) error { var k SubjectKey if err := json.Unmarshal(key, &k); err != nil { - return nil + return err } return e.onSubjectChange(ctx, k.ID, payload.Op) @@ -35,7 +36,7 @@ func (e *eventHandler) OnSubject(ctx context.Context, key json.RawMessage, paylo func (e *eventHandler) OnSubjectField(ctx context.Context, key json.RawMessage, payload Payload) error { var k SubjectFieldKey if err := json.Unmarshal(key, &k); err != nil { - return nil + return err } return e.onSubjectChange(ctx, k.ID, payload.Op) @@ -51,6 +52,8 @@ func (e *eventHandler) onSubjectChange(ctx context.Context, subjectID model.Subj if err := e.search.OnSubjectDelete(ctx, subjectID); err != nil { return errgo.Wrap(err, "search.OnSubjectDelete") } + default: + e.log.Warn("unexpected operator", zap.String("op", op)) } return nil