@@ -848,6 +848,15 @@ func (db *Database) Run(cmd interface{}, result interface{}) error {
848848 return db .run (socket , cmd , result )
849849}
850850
851+ // runOnSocket does the same as Run, but guarantees that your command will be run
852+ // on the provided socket instance; if it's unhealthy, you will receive the error
853+ // from it.
854+ func (db * Database ) runOnSocket (socket * mongoSocket , cmd interface {}, result interface {}) error {
855+ socket .Acquire ()
856+ defer socket .Release ()
857+ return db .run (socket , cmd , result )
858+ }
859+
851860// Credential holds details to authenticate with a MongoDB server.
852861type Credential struct {
853862 // Username and Password hold the basic details for authentication.
@@ -2312,6 +2321,13 @@ func (s *Session) Run(cmd interface{}, result interface{}) error {
23122321 return s .DB ("admin" ).Run (cmd , result )
23132322}
23142323
2324+ // runOnSocket does the same as Run, but guarantees that your command will be run
2325+ // on the provided socket instance; if it's unhealthy, you will receive the error
2326+ // from it.
2327+ func (s * Session ) runOnSocket (socket * mongoSocket , cmd interface {}, result interface {}) error {
2328+ return s .DB ("admin" ).runOnSocket (socket , cmd , result )
2329+ }
2330+
23152331// SelectServers restricts communication to servers configured with the
23162332// given tags. For example, the following statement restricts servers
23172333// used for reading operations to those with both tag "disk" set to
0 commit comments