@@ -131,7 +131,7 @@ func Connect(opts ...*options.ClientOptions) (*Client, error) {
131131// set in the Auth field for the first option, and Password is set for the second but with no
132132// Username, after the merge the Username field will be empty.
133133func newClient (opts ... * options.ClientOptions ) (* Client , error ) {
134- args := options .MergeClientOptions (opts ... ) // TODO: Rename from args to opts
134+ clientOpts := options .MergeClientOptions (opts ... )
135135
136136 id , err := uuid .New ()
137137 if err != nil {
@@ -144,91 +144,91 @@ func newClient(opts ...*options.ClientOptions) (*Client, error) {
144144
145145 // LocalThreshold
146146 client .localThreshold = defaultLocalThreshold
147- if args .LocalThreshold != nil {
148- client .localThreshold = * args .LocalThreshold
147+ if clientOpts .LocalThreshold != nil {
148+ client .localThreshold = * clientOpts .LocalThreshold
149149 }
150150 // Monitor
151- if args .Monitor != nil {
152- client .monitor = args .Monitor
151+ if clientOpts .Monitor != nil {
152+ client .monitor = clientOpts .Monitor
153153 }
154154 // ServerMonitor
155- if args .ServerMonitor != nil {
156- client .serverMonitor = args .ServerMonitor
155+ if clientOpts .ServerMonitor != nil {
156+ client .serverMonitor = clientOpts .ServerMonitor
157157 }
158158 // ReadConcern
159159 client .readConcern = & readconcern.ReadConcern {}
160- if args .ReadConcern != nil {
161- client .readConcern = args .ReadConcern
160+ if clientOpts .ReadConcern != nil {
161+ client .readConcern = clientOpts .ReadConcern
162162 }
163163 // ReadPreference
164164 client .readPreference = readpref .Primary ()
165- if args .ReadPreference != nil {
166- client .readPreference = args .ReadPreference
165+ if clientOpts .ReadPreference != nil {
166+ client .readPreference = clientOpts .ReadPreference
167167 }
168168 // BSONOptions
169- if args .BSONOptions != nil {
170- client .bsonOpts = args .BSONOptions
169+ if clientOpts .BSONOptions != nil {
170+ client .bsonOpts = clientOpts .BSONOptions
171171 }
172172 // Registry
173173 client .registry = defaultRegistry
174- if args .Registry != nil {
175- client .registry = args .Registry
174+ if clientOpts .Registry != nil {
175+ client .registry = clientOpts .Registry
176176 }
177177 // RetryWrites
178178 client .retryWrites = true // retry writes on by default
179- if args .RetryWrites != nil {
180- client .retryWrites = * args .RetryWrites
179+ if clientOpts .RetryWrites != nil {
180+ client .retryWrites = * clientOpts .RetryWrites
181181 }
182182 client .retryReads = true
183- if args .RetryReads != nil {
184- client .retryReads = * args .RetryReads
183+ if clientOpts .RetryReads != nil {
184+ client .retryReads = * clientOpts .RetryReads
185185 }
186186 // Timeout
187- client .timeout = args .Timeout
188- client .httpClient = args .HTTPClient
187+ client .timeout = clientOpts .Timeout
188+ client .httpClient = clientOpts .HTTPClient
189189 // WriteConcern
190- if args .WriteConcern != nil {
191- client .writeConcern = args .WriteConcern
190+ if clientOpts .WriteConcern != nil {
191+ client .writeConcern = clientOpts .WriteConcern
192192 }
193193 // AutoEncryptionOptions
194- if args .AutoEncryptionOptions != nil {
195- if err := client .configureAutoEncryption (args ); err != nil {
194+ if clientOpts .AutoEncryptionOptions != nil {
195+ if err := client .configureAutoEncryption (clientOpts ); err != nil {
196196 return nil , err
197197 }
198198 } else {
199- client .cryptFLE = args .Crypt
199+ client .cryptFLE = clientOpts .Crypt
200200 }
201201
202202 // Deployment
203- if args .Deployment != nil {
204- client .deployment = args .Deployment
203+ if clientOpts .Deployment != nil {
204+ client .deployment = clientOpts .Deployment
205205 }
206206
207207 // Set default options
208- if args .MaxPoolSize == nil {
208+ if clientOpts .MaxPoolSize == nil {
209209 defaultMaxPoolSize := uint64 (defaultMaxPoolSize )
210- args .MaxPoolSize = & defaultMaxPoolSize
210+ clientOpts .MaxPoolSize = & defaultMaxPoolSize
211211 }
212212
213- if args .Auth != nil {
213+ if clientOpts .Auth != nil {
214214 client .authenticator , err = auth .CreateAuthenticator (
215- args .Auth .AuthMechanism ,
216- topology .ConvertCreds (args .Auth ),
217- args .HTTPClient ,
215+ clientOpts .Auth .AuthMechanism ,
216+ topology .ConvertCreds (clientOpts .Auth ),
217+ clientOpts .HTTPClient ,
218218 )
219219 if err != nil {
220220 return nil , fmt .Errorf ("error creating authenticator: %w" , err )
221221 }
222222 }
223223
224- cfg , err := topology .NewConfigFromOptionsWithAuthenticator (args , client .clock , client .authenticator )
224+ cfg , err := topology .NewConfigFromOptionsWithAuthenticator (clientOpts , client .clock , client .authenticator )
225225 if err != nil {
226226 return nil , err
227227 }
228228
229229 var connectTimeout time.Duration
230- if args .ConnectTimeout != nil {
231- connectTimeout = * args .ConnectTimeout
230+ if clientOpts .ConnectTimeout != nil {
231+ connectTimeout = * clientOpts .ConnectTimeout
232232 }
233233
234234 client .serverAPI = topology .ServerAPIFromServerOptions (connectTimeout , cfg .ServerOpts )
@@ -241,7 +241,7 @@ func newClient(opts ...*options.ClientOptions) (*Client, error) {
241241 }
242242
243243 // Create a logger for the client.
244- client .logger , err = newLogger (args .LoggerOptions )
244+ client .logger , err = newLogger (clientOpts .LoggerOptions )
245245 if err != nil {
246246 return nil , fmt .Errorf ("invalid logger options: %w" , err )
247247 }
0 commit comments