github.com/mdaxf/iac@v0.0.0-20240519030858-58a061660378/vendor_skip/go.mongodb.org/mongo-driver/mongo/options/runcmdoptions.go (about) 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 options 8 9 import "go.mongodb.org/mongo-driver/mongo/readpref" 10 11 // RunCmdOptions represents options that can be used to configure a RunCommand operation. 12 type RunCmdOptions struct { 13 // The read preference to use for the operation. The default value is nil, which means that the primary read 14 // preference will be used. 15 ReadPreference *readpref.ReadPref 16 } 17 18 // RunCmd creates a new RunCmdOptions instance. 19 func RunCmd() *RunCmdOptions { 20 return &RunCmdOptions{} 21 } 22 23 // SetReadPreference sets value for the ReadPreference field. 24 func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions { 25 rc.ReadPreference = rp 26 return rc 27 } 28 29 // MergeRunCmdOptions combines the given RunCmdOptions instances into one *RunCmdOptions in a last-one-wins fashion. 30 // 31 // Deprecated: Merging options structs will not be supported in Go Driver 2.0. Users should create a 32 // single options struct instead. 33 func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions { 34 rc := RunCmd() 35 for _, opt := range opts { 36 if opt == nil { 37 continue 38 } 39 if opt.ReadPreference != nil { 40 rc.ReadPreference = opt.ReadPreference 41 } 42 } 43 44 return rc 45 }