Skip to content

Commit

Permalink
allow to use protov1 messages (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ankurs authored Sep 18, 2024
1 parent 3a05364 commit 90eaf49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/go-coldbrew/log/loggers"
"github.com/go-coldbrew/log/loggers/gokit"
nrutil "github.com/go-coldbrew/tracing/newrelic"
protov1 "github.com/golang/protobuf/proto" //nolint:staticcheck
jprom "github.com/jaegertracing/jaeger-lib/metrics/prometheus"
newrelic "github.com/newrelic/go-agent/v3/newrelic"
"github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -236,8 +237,8 @@ func signalWatcher(ctx context.Context, c *cb, dur time.Duration) {
log.Info(ctx, "signal watcher started")
for sig := range signals {
log.Info(ctx, "signal: shutdown on "+sig.String())
c.Stop(dur)
log.Info(ctx, "signal: shutdown completed "+sig.String())
err := c.Stop(dur)
log.Info(ctx, "signal: shutdown completed "+sig.String(), "err", err)
break
}
}
Expand All @@ -262,6 +263,8 @@ func (vtprotoCodec) Marshal(v any) ([]byte, error) {
return v.MarshalVT()
case proto.Message:
return proto.Marshal(v)
case protov1.Message:
return proto.Marshal(protov1.MessageV2(v))
default:
return nil, fmt.Errorf("failed to marshal, message is %T, must satisfy the vtprotoMessage interface or want proto.Message", v)
}
Expand All @@ -273,6 +276,8 @@ func (vtprotoCodec) Unmarshal(data []byte, v any) error {
return v.UnmarshalVT(data)
case proto.Message:
return proto.Unmarshal(data, v)
case protov1.Message:
return protov1.Unmarshal(data, v)
default:
return fmt.Errorf("failed to unmarshal, message is %T, must satisfy the vtprotoMessage interface or want proto.Message", v)
}
Expand Down

0 comments on commit 90eaf49

Please sign in to comment.