[GODRIVER-2865] Export a constant for the max size of a BSON document Created: 05/Jun/23 Updated: 13/Jun/23 Resolved: 13/Jun/23 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Unknown |
| Reporter: | Felipe Gasper | Assignee: | Matt Dale |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
| Description |
|
It would be nice to be able to write `bson.MaxDocSize` instead of hard-coding 16 MiB. I see that the driver internally defines such a constant; this request proposes to export that. Thank you! |
| Comments |
| Comment by Matt Dale [ 13/Jun/23 ] | |||||||||||||||||||
|
felipe.gasper@mongodb.com yeah, it's not exactly constant, although it seems to only change about once per decade. You can pull the real value from a ServerDescriptionChangedEvent. E.g. code for printing MaxDocumentSize:
| |||||||||||||||||||
| Comment by Felipe Gasper [ 13/Jun/23 ] | |||||||||||||||||||
|
Apparently the max BSON size isn’t as “constant” as I thought. | |||||||||||||||||||
| Comment by Felipe Gasper [ 13/Jun/23 ] | |||||||||||||||||||
|
matt.dale@mongodb.com: We use such a constant, e.g., in the migration-verifier to ensure that we can write out appropriate documents to note recheck tasks. If the max BSON size varies according to the server version (and theoretically could change again), then I guess this isn’t necessarily the best idea. | |||||||||||||||||||
| Comment by PM Bot [ 13/Jun/23 ] | |||||||||||||||||||
|
Hi felipe.gasper@mongodb.com! If this is still an issue for you, please open Jira to review the latest status and provide your feedback. Thanks! | |||||||||||||||||||
| Comment by Matt Dale [ 05/Jun/23 ] | |||||||||||||||||||
|
Hey felipe.gasper@mongodb.com thanks for the suggestion! I'm concerned about adding a constant for the maximum BSON document size because it technically depends on the DB version (although it hasn't changed in a long time; see a reference to previous changes here). Can you give me more details about how you would use a maximum document size constant? What logic depends on knowing the maximum document size? Do you have a way to handle errors from the database if you send a document that is too large? |