Skip to content

Commit feda36e

Browse files
authored
DOCSP-52911 Break up FAQ (#13692)
* DOCSP-52911 Break up FAQ * edits * SA review * code edit
1 parent 41b5ffc commit feda36e

File tree

6 files changed

+66
-213
lines changed

6 files changed

+66
-213
lines changed

content/golang/upcoming/source/connect/connection-options/connection-pools.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ For efficiency, create a client once for each process, and reuse it for all
5454
operations. Avoid creating a new client for each request because this will
5555
increase latency.
5656

57+
If sockets close due to any network errors, causing the total number of sockets
58+
(both in use and idle) to drop below the minimum, more sockets open until the
59+
minimum is reached.
60+
5761
Configure a Connection Pool
5862
---------------------------
5963

@@ -89,7 +93,8 @@ see the corresponding syntax:
8993

9094
* - ``minPoolSize``
9195

92-
- Minimum number of connections opened in the pool. The value of
96+
- Minimum number of connections opened in the pool. The connection pool is
97+
initialized with this number of sockets. The value of
9398
``minPoolSize`` must be less than the value of ``maxPoolSize``.
9499

95100
*Default*: ``0``
@@ -110,7 +115,8 @@ see the corresponding syntax:
110115
* - ``waitQueueTimeoutMS```
111116

112117
- Specifies the maximum wait time in milliseconds that a thread can wait
113-
for a connection to become available.
118+
for a connection to become available. An operation that waits for a socket
119+
longer than this defined length of time raises a connection error.
114120

115121
*Default*: ``0`` (no limit)
116122

content/golang/upcoming/source/data-formats/bson.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,10 @@ The ``Cursor`` type also uses the ``All()`` method, which unmarshals all
313313
documents stored in the cursor into an array at the same time.
314314

315315
The ``bson`` package includes a family of ``Marshal()`` and ``Unmarshal()``
316-
methods that work with BSON-encoded data of ``[]byte`` type.
316+
methods that work with BSON-encoded data of ``[]byte`` type. The ``bson.Marshal()`` and
317+
``bson.Unmarshal()`` methods require a parameter that can be encoded into a BSON document,
318+
such as a ``bson.D`` type. A ``Write`` error occurs if you pass an incorrect type.
319+
For example, if you pass a string to ``bson.Marshal()``, a ``WriteString`` error occurs.
317320

318321
The following code demonstrates how you can unmarshal BSON back into a
319322
user-defined struct by using methods from the ``bson`` package:

content/golang/upcoming/source/data-formats/extended-json.txt

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,53 @@ Write Extended JSON
171171
-------------------
172172

173173
You can produce an Extended JSON string from an instance of a
174-
{+language+} struct by calling the ``bson.MarshalExtJSON()`` method.
174+
{+language+} struct or BSON document by calling the ``bson.MarshalExtJSON()`` method.
175175
The following example creates an Extended JSON string in the Relaxed
176-
format from an instance of ``Person``:
176+
format from either a struct or BSON document. Select the :guilabel:`Struct` or
177+
:guilabel:`bson.D` tab to see the corresponding example:
177178

178-
.. io-code-block::
179-
:copyable: true
179+
.. tabs::
180180

181-
.. input:: /includes/data-formats/ejson.go
182-
:start-after: begin-marshal
183-
:end-before: end-marshal
184-
:language: go
185-
:emphasize-lines: 10
186-
:dedent:
181+
.. tab:: Struct
182+
:tabid: struct
187183

188-
.. output::
189-
:language: none
190-
:visible: false
184+
.. io-code-block::
185+
:copyable: true
186+
187+
.. input:: /includes/data-formats/ejson.go
188+
:start-after: begin-marshal
189+
:end-before: end-marshal
190+
:language: go
191+
:emphasize-lines: 10
192+
:dedent:
193+
194+
.. output::
195+
:language: none
196+
:visible: false
197+
198+
Extended JSON Representation:
199+
{"_id":{"$oid":"686688fa7c1a2e75405f4697"},"name":"Matteo Carisi","age":49,"birthday":{"$date":"1975-10-30T00:00:00Z"},"address":{"street":"14a Corner Court","city":"Springfield","state":"IL"},"hobbies":["cooking","birdwatching"]}
200+
201+
.. tab:: bson.D
202+
:tabid: bson.D
203+
204+
.. io-code-block::
205+
:copyable: true
206+
207+
.. input:: /includes/data-formats/ejson.go
208+
:start-after: begin-marshal-bson-v
209+
:end-before: end-marshal-bson-v
210+
:language: go
211+
:emphasize-lines: 3
212+
:dedent:
213+
214+
.. output::
215+
:language: none
216+
:visible: false
217+
218+
Extended JSON Representation:
219+
{"hello":"world","number":1}
191220

192-
Extended JSON Representation:
193-
{"_id":{"$oid":"686688fa7c1a2e75405f4697"},"name":"Matteo Carisi","age":49,"birthday":{"$date":"1975-10-30T00:00:00Z"},"address":{"street":"14a Corner Court","city":"Springfield","state":"IL"},"hobbies":["cooking","birdwatching"]}
194221

195222
The second parameter to ``MarshalExtJSON()`` determines if the output
196223
string is in Canonical (Extended) format or Relaxed format. The

content/golang/upcoming/source/includes/data-formats/ejson.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ func main() {
5050
Hobbies: []string{"cooking", "birdwatching"},
5151
}
5252

53-
newExtJsonString, err := bson.MarshalExtJSON(person, false, true)
53+
newExtJsonStringFromStruct, err := bson.MarshalExtJSON(person, false, true)
5454
if err != nil {
5555
log.Fatal(err)
5656
}
5757

58-
fmt.Printf("Extended JSON Representation:\n%s\n", newExtJsonString)
58+
fmt.Printf("Extended JSON Representation:\n%s\n", newExtJsonStringFromStruct)
5959
// end-marshal
6060

6161
// begin-marshal-fmt
@@ -67,4 +67,14 @@ func main() {
6767
fmt.Printf("%s\n", formattedString)
6868
// end-marshal-fmt
6969

70+
// begin-marshal-bson-v
71+
bsonDocument := bson.D{{"hello", "world"}, {"number", 1}}
72+
73+
newExtJsonStringFromBson, err := bson.MarshalExtJSON(bsonDocument, false, true)
74+
if err != nil {
75+
panic(err)
76+
}
77+
78+
fmt.Printf("Extended JSON Representation:\n%s\n", newExtJsonStringFromBson)
79+
// end-marshal-bson-v
7080
}

content/golang/upcoming/source/reference.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ Reference
1212
Compatibility </reference/compatibility>
1313
Upgrade Guides </reference/upgrade>
1414
Quick Reference </reference/quick-reference>
15-
FAQ </reference/faq>
1615

content/golang/upcoming/source/reference/faq.txt

Lines changed: 0 additions & 192 deletions
This file was deleted.

0 commit comments

Comments
 (0)