Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thrift to v0.20.0 #646

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/Shopify/sarama v1.29.1
github.com/alicebob/miniredis/v2 v2.14.3
github.com/apache/thrift v0.19.0
github.com/apache/thrift v0.20.0
github.com/avast/retry-go v3.0.0+incompatible
github.com/fsnotify/fsnotify v1.5.4
github.com/getsentry/sentry-go v0.11.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZp
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.14.3 h1:QWoo2wchYmLgOB6ctlTt2dewQ1Vu6phl+iQbwT8SYGo=
github.com/alicebob/miniredis/v2 v2.14.3/go.mod h1:gquAfGbzn92jvtrSC69+6zZnwSODVXVpYDRaGhWaL6I=
github.com/apache/thrift v0.19.0 h1:sOqkWPzMj7w6XaYbJQG7m4sGqVolaW/0D28Ln7yPzMk=
github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07Dc0QC1I=
github.com/apache/thrift v0.20.0 h1:631+KvYbsBZxmuJjYwhezVsrfc/TbqtZV4QcxOX1fOI=
github.com/apache/thrift v0.20.0/go.mod h1:hOk1BQqcp2OLzGsyVXdfMk7YFlMxK3aoEVhjD06QhB8=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
Expand Down
2 changes: 1 addition & 1 deletion internal/gen-go/reddit/baseplate/GoUnusedProtection__.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions internal/gen-go/reddit/baseplate/baseplate-consts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 92 additions & 12 deletions internal/gen-go/reddit/baseplate/baseplate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions internal/thriftint/baseplate_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package thriftint_test
import (
"errors"
"fmt"
"io"
"log/slog"
"strings"
"testing"

"github.com/apache/thrift/lib/go/thrift"
Expand Down Expand Up @@ -138,3 +141,44 @@ func TestWrapBaseplateError(t *testing.T) {
}
})
}

func TestSlogErrorValue(t *testing.T) {
err := &baseplatethrift.Error{
Message: thrift.StringPtr("message"),
Code: thrift.Int32Ptr(1),
Retryable: thrift.BoolPtr(true),
Details: map[string]string{
"foo": "bar",
},
}
opts := &slog.HandlerOptions{
AddSource: false,
ReplaceAttr: func(groups []string, a slog.Attr) slog.Attr {
// drop time
if len(groups) == 0 && a.Key == slog.TimeKey {
return slog.Attr{}
}
return a
},
}

for label, base := range map[string]func(w io.Writer) slog.Handler{
"json": func(w io.Writer) slog.Handler {
return slog.NewJSONHandler(w, opts)
},
"text": func(w io.Writer) slog.Handler {
return slog.NewTextHandler(w, opts)
},
} {
t.Run(label, func(t *testing.T) {
// When using thrift 0.20.0+, make sure that slog logs the same before and
// after thriftint.WrapBaseplateError.
var gotWriter, wantWriter strings.Builder
slog.New(base(&gotWriter)).Info("foo", "err", thriftint.WrapBaseplateError(err))
slog.New(base(&wantWriter)).Info("foo", "err", err)
if got, want := gotWriter.String(), wantWriter.String(); got != want {
t.Errorf("got %q want %q", got, want)
}
})
}
}
4 changes: 4 additions & 0 deletions log/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func (w Wrapper) Log(ctx context.Context, msg string) {
}

// ToThriftLogger wraps Wrapper into thrift.Logger.
//
// Deprecated: thrift.Logger is deprecated.
func (w Wrapper) ToThriftLogger() thrift.Logger {
if w == nil {
w = DefaultWrapper
Expand Down Expand Up @@ -180,6 +182,8 @@ func (w *Wrapper) UnmarshalText(text []byte) error {
var _ encoding.TextUnmarshaler = (*Wrapper)(nil)

// WrapToThriftLogger wraps a Wrapper into thrift.Logger.
//
// Deprecated: thrift.Logger is deprecated.
func WrapToThriftLogger(w Wrapper) thrift.Logger {
return w.ToThriftLogger()
}
Expand Down
Loading
Loading