[GODRIVER-592] Reverse Dependencies of bson and bsoncodec Created: 08/Oct/18  Updated: 13/Oct/18  Resolved: 13/Oct/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 0.0.15
Fix Version/s: 0.0.17

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Kristofer Brandow (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to GODRIVER-413 Implement Improved BSON Design Closed

 Description   

TheĀ  bsoncodec package currently depends on the bson package. This means that the types within the bson package cannot marshal themselves. This causes problems for constructing *bson.Element's from an empty interface, but it also means that a ToExtJSON method cannot be part of a *bson.Document.

Additionally, with functions like Marshal and Unmarshal being part of the bsoncodec package, users are required to import both packages for most of their BSON usage. This includes the Encoder and Decoder types.

To fix these problems and prepare for further improvements to the BSON library, reverse the dependency between bson and bsoncodec to have the bson package depend on the bsoncodec package.

Split the ValueReader and ValueWriter types into their own package called bsonrw and create a public test implementation in a package called bsonrwtest.



 Comments   
Comment by Kristofer Brandow (Inactive) [ 13/Oct/18 ]

Code Review: https://review.gerrithub.io/c/mongodb/mongo-go-driver/+/428114.

Comment by Githook User [ 13/Oct/18 ]

Author:

{'name': 'Kris Brandow', 'email': 'kris@mongodb.com', 'username': 'skriptble'}

Message: Reverse dependencies between bsoncodec and bson

This commit reverses the dependency between the bson and bsoncodec
package. This allows the bson package to contain the Marshal and
Unmarshal family of functions and the Encoder and Decoder types. This
allows future types in the bson package to handle the empty interface.
The default encoders and decoders are split across two packages, because
the bsoncodec package can only provide encoders and decoders for
non-bson package types. The empty interface decoder is defined twice: a
partial version in bsoncdec and a complete version in the bson package.
Almost all users should use a Registry created from both sets of
encoders and decoders.

The bsoncodec package was split into the bsonrw and bsoncodec packages.
The new bsonrw package contains the ValueReader and ValueWriter
definitions and implementations. A new bsonrwtest package was created
with the previously used llValueReaderWriter type that is useful for
unit testing a ValueReader or ValueWriter implementation. This allows
users outside of the bsoncodec and bsonrw packages to use this type with
their own ValueReader and ValueWriter implementations.

The llbson package is renamed bsoncore and moved out of internal. This
will allow other users to directly use this low level bson package.
Eventually the entire BSON library will use bsoncore to handle reading
and writing BSON from and to bytes. This package replaces the elements
package, which will be removed in a future commit.

GODRIVER-592

Change-Id: I1e2dabc83cae9705fc062a6b763e0d2b91cde3ef
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/44d349d1886bcc181046312daee15bb2533a2d10

Generated at Thu Feb 08 08:34:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.