[GODRIVER-329] Make bson.Decoder an interface Created: 03/Apr/18  Updated: 28/Oct/23  Resolved: 15/May/18

Status: Closed
Project: Go Driver
Component/s: BSON
Affects Version/s: 0.0.2
Fix Version/s: 0.0.5

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

Epic Link: GODRIVER BSON public API improvements

 Description   

To support using pluggable bson.Decoders, make the bson.Decoder type an interface. This will be useful for adding mgo/bson compatibility.



 Comments   
Comment by Githook User [ 15/May/18 ]

Author:

{'email': 'garen@tychoish.com', 'username': 'tychoish', 'name': 'tycho garen'}

Message: GODRIVER-329: decoder interface

Change-Id: Ib2823cd16bc5c66dc9b67fe9b4f62c22a9e96eb0
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/60a04ea0aba1cbffa678a872bff3ab5225fa5c74

Comment by Kristofer Brandow (Inactive) [ 15/May/18 ]

These are valid questions that I think can be answered with the new encoder/decoder design I'm writing. For now, let's just make this type an interface, since it'll get us one step closer to our goal.

Comment by Sam Kleinman (Inactive) [ 15/May/18 ]

I'd like to have more context with how you want this to work.

It's fairly straight forward to move the Decoder into an interface, but it's not clear how this would be useful for any kind of plug-ability without a layer of factories and what not as the decoder (and encoder) are presently stateful. I'm willing to make the change (and I'm generally in favor of exposing package functionality via interfaces rather than opaque concrete types,) but I don't think that this alone will solve our problem.

Is there any reason to not just have an EncoderFunc and DecoderFunc types that have the signatures of Marshal/Unmarshal, and then make setting those an option on the client (which would propagate (and maybe me configurable at the level of) db/collection options. This means making transform document private, which is probably good.) and reworking slightly to get the plug-able behavior we want.

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