-
Notifications
You must be signed in to change notification settings - Fork 895
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
GODRIVER-2976 Remove deprecated BSON code. #1698
Conversation
API Change Report./bsonincompatible changesCompareTimestamp: removed |
41bdaad
to
fd391ba
Compare
c712eba
to
0832721
Compare
0832721
to
6d76528
Compare
// ExtJSONValueReaderPool is a pool for ValueReaders that read ExtJSON. | ||
// | ||
// Deprecated: ExtJSONValueReaderPool will not be supported in Go Driver 2.0. | ||
type ExtJSONValueReaderPool struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code
// | ||
// Deprecated: Using a custom registry to marshal individual BSON values will not be supported in Go | ||
// Driver 2.0. | ||
func MarshalValueWithRegistry(r *Registry, val interface{}) (Type, []byte, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only called in the mongo
package. Moved there.
bson/reader.go
Outdated
// The bytes of the value will be appended to dst. | ||
// | ||
// Deprecated: BytesReader will not be supported in Go Driver 2.0. | ||
type BytesReader interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used by copier
.
// getEncoder takes a writer, BSON options, and a BSON registry and returns a properly configured | ||
// bson.Encoder that writes to the given writer. | ||
func getEncoder( | ||
w io.Writer, | ||
opts *options.BSONOptions, | ||
reg *bson.Registry, | ||
) (*bson.Encoder, error) { | ||
vw := bvwPool.Get(w) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stop pooling since Put
is never called.
a097df1
to
96d0d2c
Compare
@@ -30,28 +30,6 @@ func noerr(t *testing.T, err error) { | |||
} | |||
} | |||
|
|||
func TestCompareTimestamp(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code
96d0d2c
to
87a2c5a
Compare
// NewExtJSONValueWriterPool creates a new pool for ValueWriter instances that write to ExtJSON. | ||
// | ||
// Deprecated: ExtJSONValueWriterPool will not be supported in Go Driver 2.0. | ||
func NewExtJSONValueWriterPool() *ExtJSONValueWriterPool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in "marshal.go".
// ErrNotPointer is returned when a non-pointer type is provided to LookupDecoder. | ||
// | ||
// Deprecated: ErrNotPointer will not be supported in Go Driver 2.0. | ||
var ErrNotPointer = errors.New("non-pointer provided to LookupDecoder") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code
// NewValueReaderPool instantiates a new ValueReaderPool. | ||
// | ||
// Deprecated: ValueReaderPool will not be supported in Go Driver 2.0. | ||
func NewValueReaderPool() *ValueReaderPool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code
// NewValueWriterPool creates a new pool for ValueWriter instances that write to BSON. | ||
// | ||
// Deprecated: ValueWriterPool will not be supported in Go Driver 2.0. | ||
func NewValueWriterPool() *ValueWriterPool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in "default_value_encoders.go".
bson/writer.go
Outdated
// implement ValueWriter may also implement this interface. | ||
// | ||
// Deprecated: BytesWriter will not be supported in Go Driver 2.0. | ||
type BytesWriter interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used in copier
.
// ValueWriterFlusher is a superset of ValueWriter that exposes functionality to flush to the underlying buffer. | ||
// | ||
// Deprecated: ValueWriterFlusher will not be supported in Go Driver 2.0. | ||
type ValueWriterFlusher interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only used by ValueWriterPool.GetAtModeElement()
, which is only called by MarshalValueWithRegistry()
.
mongo/util.go
Outdated
}, | ||
} | ||
|
||
func marshalValueWithRegistry(r *bson.Registry, val interface{}) (bsoncore.Value, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant with the existing marshalValue
function. The memory optimization is good, but we should make that memory optimization in a single place for all callers, either in this PR or in another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've switched to marshalValue
. Optimization can be done in another PR.
bson/registry_test.go
Outdated
if !cmp.Equal(goterr.Error(), wanterr, cmp.Comparer(assert.CompareErrors)) { | ||
t.Errorf("errors did not match: got %#v, want %q", goterr, wanterr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use assert.EqualError
.
if !cmp.Equal(goterr.Error(), wanterr, cmp.Comparer(assert.CompareErrors)) { | |
t.Errorf("errors did not match: got %#v, want %q", goterr, wanterr) | |
assert.EqualError(t, goterr, wanterr, "errors did not match") |
bson/copier_test.go
Outdated
t.Run("CopyValue error", func(t *testing.T) { | ||
want := errors.New("CopyValue error") | ||
llvrw := &TestValueReaderWriter{t: t, bsontype: TypeString, err: want, errAfter: llvrwReadString} | ||
_, _, got := appendValueBytes(make([]byte, 0), llvrw) | ||
if !assert.CompareErrors(got, want) { | ||
t.Errorf("Errors do not match. got %v; want %v", got, want) | ||
} | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This subtest should be moved to CopyValueToBytes
.
} | ||
}) | ||
// tests covering GODRIVER-2779 | ||
t.Run("UnmarshalValueWithRegistry with custom registry", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom registry's can still be defined using NewDecoder
. Do we currently apply the test matrix for this test to NewDecoder
. If not, instead of removing this test suggest updating it to the new pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to TestUnmarshalWithRegistry
in "unmarshal_test.go"
bson/unmarshal_value_test.go
Outdated
@@ -110,13 +56,11 @@ func BenchmarkSliceCodecUnmarshal(b *testing.B) { | |||
bytes: bsoncore.AppendString(nil, strings.Repeat("t", 4096)), | |||
}, | |||
} | |||
reg := NewRegistry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using NewDecoder
with SetRegistry
to preserve the original intention of this benchmark.
atomic.AddInt32(&c.numConnsCheckedOut, 1) | ||
case event.ConnectionCheckedIn: | ||
c.numConnsCheckedOut-- | ||
atomic.AddInt32(&c.numConnsCheckedOut, -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated for racing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 👍
GODRIVER-2976
Summary
Remove all deprecated BSON code.
Background & Motivation