Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dialinfo := mgo.DialInfo{
- Addrs: {"1.2.3.45","1.2.3.56"}
- Database: Mongo1,
- Username: User,
- Password: Pwd,
- Timeout: 60 * time.Second,
- DialServer: func(addr *mgo.ServerAddr) (net.Conn, error) {
- conn, err := connectToCluster("172.12.13.145")
- if err != nil {
- fmt.Println("couldn't connect to the cluster, trying again..")
- return nil, err
- }
- remote, err := conn.Dial("tcp", addr.String())
- if err != nil {
- fmt.Println("couldn't connect to the mongodb server:", addr.String())
- }
- return remote, err
- },
- }
- session, err = mgo.DialWithInfo(dialinfo)
- dialinfo := mgo.DialInfo{
- Addrs: {"mongodbserver1","mongodbserver2"}
- Database: Mongo1,
- Username: User,
- Password: Pwd,
- Timeout: 60 * time.Second,
- DialServer: func(addr *mgo.ServerAddr) (net.Conn, error) {
- conn, err := connectToCluster("172.12.13.145")
- if err != nil {
- fmt.Println("couldn't connect to the cluster, trying again..")
- return nil, err
- }
- remote, err := conn.Dial("tcp", addr.String())
- if err != nil {
- fmt.Println("couldn't connect to the mongodb server:", addr.String())
- }
- return remote, err
- },
- }
- session, err = mgo.DialWithInfo(dialinfo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement