Debian Codegraph @

mongo/description/server_selector.go

raw symbols SCIP
1 // Copyright (C) MongoDB, Inc. 2017-present.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may
4 // not use this file except in compliance with the License. You may obtain
5 // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7 package descriptionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/
8
9 import (
10 "encoding/jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/"
11 "fmtscip-go gomod github.com/golang/go/src go1.18 fmt/"
12 "mathscip-go gomod github.com/golang/go/src go1.18 math/"
13 "timescip-go gomod github.com/golang/go/src go1.18 time/"
14
15 "go.mongodb.org/mongo-driver/mongo/readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/"
16 "go.mongodb.org/mongo-driver/tagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/tag`/"
17 )
18
19 // ServerSelector is an interface implemented by types that can perform server selection given a topology description
20 // and list of candidate servers. The selector should filter the provided candidates list and return a subset that
21 // matches some criteria.
22 type ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# interface {
23 SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector#SelectServer.(Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error)
24 }
25
26 // ServerSelectorFunc is a function that can be used as a ServerSelector.
27 type ServerSelectorFuncscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelectorFunc# func(Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error)
28
29 // SelectServer implements the ServerSelector interface.
30 func (ssf ServerSelectorFuncscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelectorFunc#) SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelectorFunc#SelectServer().(t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, s []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
31 return ssf(t, s)
32 }
33
34 // serverSelectorInfo contains metadata concerning the server selector for the
35 // purpose of publication.
36 type serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# struct {
37 Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Type. string
38 Datascip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Data. string `json:",omitempty"`
39 Selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Selectors. []serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# `json:",omitempty"`
40 }
41
42 // String returns the JSON string representation of the serverSelectorInfo.
43 func (sss serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#String().() string {
44 bytes, _ := jsonscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.18 `encoding/json`/Marshal().(sss)
45
46 return string(bytes)
47 }
48
49 // serverSelectorInfoGetter is an interface that defines an info() method to
50 // get the serverSelectorInfo.
51 type serverSelectorInfoGetterscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfoGetter# interface {
52 infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfoGetter#info.() serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#
53 }
54
55 type compositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector# struct {
56 selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#selectors. []ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector#
57 }
58
59 func (cs *compositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#) infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#info().() serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# {
60 csInfo := serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#{Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Type.: "compositeSelector"}
61
62 for _, sel := range cs.selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#selectors. {
63 if getter, ok := sel.(serverSelectorInfoGetterscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfoGetter#); ok {
64 csInfo.Selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Selectors. = append(csInfo.Selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Selectors., getter.infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfoGetter#info.())
65 }
66 }
67
68 return csInfo
69 }
70
71 // String returns the JSON string representation of the compositeSelector.
72 func (cs *compositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#String().() string {
73 return cs.infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#info().().Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#String().()
74 }
75
76 // CompositeSelector combines multiple selectors into a single selector by applying them in order to the candidates
77 // list.
78 //
79 // For example, if the initial candidates list is [s0, s1, s2, s3] and two selectors are provided where the first
80 // matches s0 and s1 and the second matches s1 and s2, the following would occur during server selection:
81 //
82 // 1. firstSelector([s0, s1, s2, s3]) -> [s0, s1]
83 // 2. secondSelector([s0, s1]) -> [s1]
84 //
85 // The final list of candidates returned by the composite selector would be [s1].
86 func CompositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/CompositeSelector().(selectors []ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector#) ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# {
87 return &compositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#{selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#selectors.: selectors}
88 }
89
90 func (cs *compositeSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#) SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#SelectServer().(t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
91 var err error
92 for _, sel := range cs.selectorsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/compositeSelector#selectors. {
93 candidates, err = sel.SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector#SelectServer.(t, candidates)
94 if err != nil {
95 return nil, err
96 }
97 }
98 return candidates, nil
99 }
100
101 type latencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector# struct {
102 latencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#latency. timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration#
103 }
104
105 // LatencySelector creates a ServerSelector which selects servers based on their average RTT values.
106 func LatencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/LatencySelector().(latency timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration#) ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# {
107 return &latencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#{latencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#latency.: latency}
108 }
109
110 func (latencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#) infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#info().() serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# {
111 return serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#{Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Type.: "latencySelector"}
112 }
113
114 func (selector latencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#String().() string {
115 return selector.infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#info().().Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#String().()
116 }
117
118 func (selector *latencySelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#) SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#SelectServer().(t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
119 if selector.latencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#latency. < 0 {
120 return candidates, nil
121 }
122 if t.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Kind. == LoadBalancedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/LoadBalanced. {
123 // In LoadBalanced mode, there should only be one server in the topology and it must be selected.
124 return candidates, nil
125 }
126
127 switch len(candidates) {
128 case 0, 1:
129 return candidates, nil
130 default:
131 min := timescip-go gomod github.com/golang/go/src go1.18 time/.Durationscip-go gomod github.com/golang/go/src go1.18 time/Duration#(mathscip-go gomod github.com/golang/go/src go1.18 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.18 math/MaxInt64.)
132 for _, candidate := range candidates {
133 if candidate.AverageRTTSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#AverageRTTSet. {
134 if candidate.AverageRTTscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#AverageRTT. < min {
135 min = candidate.AverageRTTscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#AverageRTT.
136 }
137 }
138 }
139
140 if min == mathscip-go gomod github.com/golang/go/src go1.18 math/.MaxInt64scip-go gomod github.com/golang/go/src go1.18 math/MaxInt64. {
141 return candidates, nil
142 }
143
144 max := min + selector.latencyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/latencySelector#latency.
145
146 viableIndexes := make([]int, 0, len(candidates))
147 for i, candidate := range candidates {
148 if candidate.AverageRTTSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#AverageRTTSet. {
149 if candidate.AverageRTTscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#AverageRTT. <= max {
150 viableIndexes = append(viableIndexes, i)
151 }
152 }
153 }
154 if len(viableIndexes) == len(candidates) {
155 return candidates, nil
156 }
157 result := make([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, len(viableIndexes))
158 for i, idx := range viableIndexes {
159 result[i] = candidates[idx]
160 }
161 return result, nil
162 }
163 }
164
165 type writeServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector# struct{}
166
167 // WriteSelector selects all the writable servers.
168 func WriteSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/WriteSelector().() ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# {
169 return writeServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#{}
170 }
171
172 func (writeServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#) infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#info().() serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# {
173 return serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#{Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Type.: "writeSelector"}
174 }
175
176 func (selector writeServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#String().() string {
177 return selector.infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#info().().Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#String().()
178 }
179
180 func (writeServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#) SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/writeServerSelector#SelectServer().(t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
181 switch t.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Kind. {
182 case Singlescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Single., LoadBalancedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/LoadBalanced.:
183 return candidates, nil
184 default:
185 // Determine the capacity of the results slice.
186 selected := 0
187 for _, candidate := range candidates {
188 switch candidate.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#Kind. {
189 case Mongosscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Mongos., RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary., Standalonescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Standalone.:
190 selected++
191 }
192 }
193
194 // Append candidates to the results slice.
195 result := make([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, 0, selected)
196 for _, candidate := range candidates {
197 switch candidate.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#Kind. {
198 case Mongosscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Mongos., RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary., Standalonescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Standalone.:
199 result = append(result, candidate)
200 }
201 }
202 return result, nil
203 }
204 }
205
206 type readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector# struct {
207 rpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#rp. *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#
208 isOutputAggregatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#isOutputAggregate. bool
209 }
210
211 // ReadPrefSelector selects servers based on the provided read preference.
212 func ReadPrefSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ReadPrefSelector().(rp *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#) ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# {
213 return readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#{
214 rpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#rp.: rp,
215 isOutputAggregatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#isOutputAggregate.: false,
216 }
217 }
218
219 func (selector readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#) infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#info().() serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo# {
220 return serverSelectorInfoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#{
221 Typescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Type.: "readPrefSelector",
222 Datascip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#Data.: selector.rpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#rp..Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#String().(),
223 }
224 }
225
226 func (selector readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#) Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#String().() string {
227 return selector.infoscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#info().().Stringscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/serverSelectorInfo#String().()
228 }
229
230 func (selector readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#) SelectServerscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#SelectServer().(t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
231 if t.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Kind. == LoadBalancedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/LoadBalanced. {
232 // In LoadBalanced mode, there should only be one server in the topology and it must be selected. We check
233 // this before checking MaxStaleness support because there's no monitoring in this mode, so the candidate
234 // server wouldn't have a wire version set, which would result in an error.
235 return candidates, nil
236 }
237
238 switch t.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Kind. {
239 case Singlescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Single.:
240 return candidates, nil
241 case ReplicaSetNoPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ReplicaSetNoPrimary., ReplicaSetWithPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ReplicaSetWithPrimary.:
242 return selectForReplicaSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectForReplicaSet().(selector.rpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#rp., selector.isOutputAggregatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#isOutputAggregate., t, candidates)
243 case Shardedscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Sharded.:
244 return selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, Mongosscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Mongos.), nil
245 }
246
247 return nil, nil
248 }
249
250 // OutputAggregateSelector selects servers based on the provided read preference
251 // given that the underlying operation is aggregate with an output stage.
252 func OutputAggregateSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/OutputAggregateSelector().(rp *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#) ServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerSelector# {
253 return readPrefServerSelectorscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#{
254 rpscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#rp.: rp,
255 isOutputAggregatescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/readPrefServerSelector#isOutputAggregate.: true,
256 }
257 }
258
259 func selectForReplicaSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectForReplicaSet().(rp *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#, isOutputAggregate bool, t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) ([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, error) {
260 if err := verifyMaxStalenessscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/verifyMaxStaleness().(rp, t); err != nil {
261 return nil, err
262 }
263
264 // If underlying operation is an aggregate with an output stage, only apply read preference
265 // if all candidates are 5.0+. Otherwise, operate under primary read preference.
266 if isOutputAggregate {
267 for _, s := range candidates {
268 if s.WireVersionscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#WireVersion..Maxscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/VersionRange#Max. < 13 {
269 return selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.), nil
270 }
271 }
272 }
273
274 switch rp.Modescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#Mode().() {
275 case readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.PrimaryModescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/PrimaryMode.:
276 return selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.), nil
277 case readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.PrimaryPreferredModescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/PrimaryPreferredMode.:
278 selected := selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.)
279
280 if len(selected) == 0 {
281 selected = selectSecondariesscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectSecondaries().(rp, candidates)
282 return selectByTagSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByTagSet().(selected, rp.TagSetsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#TagSets().()), nil
283 }
284
285 return selected, nil
286 case readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.SecondaryPreferredModescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/SecondaryPreferredMode.:
287 selected := selectSecondariesscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectSecondaries().(rp, candidates)
288 selected = selectByTagSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByTagSet().(selected, rp.TagSetsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#TagSets().())
289 if len(selected) > 0 {
290 return selected, nil
291 }
292 return selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.), nil
293 case readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.SecondaryModescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/SecondaryMode.:
294 selected := selectSecondariesscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectSecondaries().(rp, candidates)
295 return selectByTagSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByTagSet().(selected, rp.TagSetsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#TagSets().()), nil
296 case readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.NearestModescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/NearestMode.:
297 selected := selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.)
298 selected = append(selected, selectSecondariesscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectSecondaries().(rp, candidates)...)
299 return selectByTagSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByTagSet().(selected, rp.TagSetsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#TagSets().()), nil
300 }
301
302 return nil, fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("unsupported mode: %d", rp.Modescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#Mode().())
303 }
304
305 func selectSecondariesscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectSecondaries().(rp *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#, candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#) []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server# {
306 secondaries := selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSSecondaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSSecondary.)
307 if len(secondaries) == 0 {
308 return secondaries
309 }
310 if maxStaleness, set := rp.MaxStalenessscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#MaxStaleness().(); set {
311 primaries := selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates, RSPrimaryscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/RSPrimary.)
312 if len(primaries) == 0 {
313 baseTime := secondaries[0].LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime.
314 for i := 1; i < len(secondaries); i++ {
315 if secondaries[i].LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime..Afterscip-go gomod github.com/golang/go/src go1.18 time/Time#After().(baseTime) {
316 baseTime = secondaries[i].LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime.
317 }
318 }
319
320 var selected []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#
321 for _, secondary := range secondaries {
322 estimatedStaleness := baseTime.Subscip-go gomod github.com/golang/go/src go1.18 time/Time#Sub().(secondary.LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime.) + secondary.HeartbeatIntervalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#HeartbeatInterval.
323 if estimatedStaleness <= maxStaleness {
324 selected = append(selected, secondary)
325 }
326 }
327
328 return selected
329 }
330
331 primary := primaries[0]
332
333 var selected []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#
334 for _, secondary := range secondaries {
335 estimatedStaleness := secondary.LastUpdateTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastUpdateTime..Subscip-go gomod github.com/golang/go/src go1.18 time/Time#Sub().(secondary.LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime.) - primary.LastUpdateTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastUpdateTime..Subscip-go gomod github.com/golang/go/src go1.18 time/Time#Sub().(primary.LastWriteTimescip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#LastWriteTime.) + secondary.HeartbeatIntervalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#HeartbeatInterval.
336 if estimatedStaleness <= maxStaleness {
337 selected = append(selected, secondary)
338 }
339 }
340 return selected
341 }
342
343 return secondaries
344 }
345
346 func selectByTagSetscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByTagSet().(candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, tagSets []tagscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/tag`/.Setscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/tag`/Set#) []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server# {
347 if len(tagSets) == 0 {
348 return candidates
349 }
350
351 for _, ts := range tagSets {
352 // If this tag set is empty, we can take a fast path because the empty list is a subset of all tag sets, so
353 // all candidate servers will be selected.
354 if len(ts) == 0 {
355 return candidates
356 }
357
358 var results []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#
359 for _, s := range candidates {
360 // ts is non-empty, so only servers with a non-empty set of tags need to be checked.
361 if len(s.Tagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#Tags.) > 0 && s.Tagsscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#Tags..ContainsAllscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/tag`/Set#ContainsAll().(ts) {
362 results = append(results, s)
363 }
364 }
365
366 if len(results) > 0 {
367 return results
368 }
369 }
370
371 return []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#{}
372 }
373
374 func selectByKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/selectByKind().(candidates []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, kind ServerKindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/ServerKind#) []Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server# {
375 // Record the indices of viable candidates first and then append those to the returned slice
376 // to avoid appending costly Server structs directly as an optimization.
377 viableIndexes := make([]int, 0, len(candidates))
378 for i, s := range candidates {
379 if s.Kindscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#Kind. == kind {
380 viableIndexes = append(viableIndexes, i)
381 }
382 }
383 if len(viableIndexes) == len(candidates) {
384 return candidates
385 }
386 result := make([]Serverscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#, len(viableIndexes))
387 for i, idx := range viableIndexes {
388 result[i] = candidates[idx]
389 }
390 return result
391 }
392
393 func verifyMaxStalenessscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/verifyMaxStaleness().(rp *readprefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/.ReadPrefscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#, t Topologyscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#) error {
394 maxStaleness, set := rp.MaxStalenessscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/readpref`/ReadPref#MaxStaleness().()
395 if !set {
396 return nil
397 }
398
399 if maxStaleness < 90*timescip-go gomod github.com/golang/go/src go1.18 time/.Secondscip-go gomod github.com/golang/go/src go1.18 time/Second. {
400 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().("max staleness (%s) must be greater than or equal to 90s", maxStaleness)
401 }
402
403 if len(t.Serversscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Servers.) < 1 {
404 // Maybe we should return an error here instead?
405 return nil
406 }
407
408 // we'll assume all candidates have the same heartbeat interval.
409 s := t.Serversscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Topology#Servers.[0]
410 idleWritePeriod := 10 * timescip-go gomod github.com/golang/go/src go1.18 time/.Secondscip-go gomod github.com/golang/go/src go1.18 time/Second.
411
412 if maxStaleness < s.HeartbeatIntervalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#HeartbeatInterval.+idleWritePeriod {
413 return fmtscip-go gomod github.com/golang/go/src go1.18 fmt/.Errorfscip-go gomod github.com/golang/go/src go1.18 fmt/Errorf().(
414 "max staleness (%s) must be greater than or equal to the heartbeat interval (%s) plus idle write period (%s)",
415 maxStaleness, s.HeartbeatIntervalscip-go gomod go.mongodb.org/mongo-driver . `go.mongodb.org/mongo-driver/mongo/description`/Server#HeartbeatInterval., idleWritePeriod,
416 )
417 }
418
419 return nil
420 }