File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -247,10 +247,7 @@ func (l *clientImpl) ConfigDatabase() *mongo.Database {
247247}
248248
249249func (l * clientImpl ) AdminCommand (ctx context.Context , cmd bson.D , opts ... * options.RunCmdOptions ) * mongo.SingleResult {
250- cmd = append (cmd ,
251- bson.E {"readConcern" , l .options .ReadConcern },
252- bson.E {"writeConcern" , l .options .WriteConcern },
253- )
250+ cmd = l .applyOptonsFromConnString (cmd )
254251 return l .client .Database (defs .DB ).RunCommand (ctx , cmd , opts ... )
255252}
256253
@@ -294,6 +291,28 @@ func (l *clientImpl) AgentsStatusCollection() *mongo.Collection {
294291 return l .client .Database (defs .DB ).Collection (defs .AgentsStatusCollection )
295292}
296293
294+ func (l * clientImpl ) applyOptonsFromConnString (cmd bson.D ) bson.D {
295+ if len (cmd ) == 0 {
296+ return cmd
297+ }
298+
299+ cmdName := cmd [0 ].Key
300+ switch cmdName {
301+ case "create" :
302+ if l .options .WriteConcern != nil {
303+ cmd = append (cmd , bson.E {"writeConcern" , l .options .WriteConcern })
304+ }
305+ default :
306+ // do nothing for all other commands:
307+ // flushRouterConfig
308+ // _configsvrBalancerStart
309+ // _configsvrBalancerStop
310+ // _configsvrBalancerStatus
311+ }
312+
313+ return cmd
314+ }
315+
297316var ErrInvalidConnection = errors .New ("invalid mongo connection" )
298317
299318type Client interface {
You can’t perform that action at this time.
0 commit comments