mdbc/readpref.go

31 lines
593 B
Go

package mdbc
import "go.mongodb.org/mongo-driver/mongo/readpref"
type ReadPref uint8
const (
PrimaryMode ReadPref = iota + 1
PrimaryPreferredMode
SecondaryMode
SecondaryPreferredMode
NearestMode
)
func readPref(pref ReadPref) *readpref.ReadPref {
switch pref {
case PrimaryMode:
return readpref.Primary()
case PrimaryPreferredMode:
return readpref.PrimaryPreferred()
case SecondaryMode:
return readpref.Secondary()
case SecondaryPreferredMode:
return readpref.SecondaryPreferred()
case NearestMode:
return readpref.Nearest()
default:
return readpref.Primary()
}
}