Skip to content

Commit

Permalink
chore: add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
trim21 committed Oct 14, 2024
1 parent be0fe62 commit d7b4b16
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions canal/on_subject.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import (
"encoding/json"

"github.com/trim21/errgo"
"go.uber.org/zap"

"github.com/bangumi/server/internal/model"
)

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)
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit d7b4b16

Please sign in to comment.