Advertisement
Guest User

Untitled

a guest
Aug 15th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. dialinfo := mgo.DialInfo{
  2. Addrs: {"1.2.3.45","1.2.3.56"}
  3. Database: Mongo1,
  4. Username: User,
  5. Password: Pwd,
  6. Timeout: 60 * time.Second,
  7. DialServer: func(addr *mgo.ServerAddr) (net.Conn, error) {
  8. conn, err := connectToCluster("172.12.13.145")
  9. if err != nil {
  10. fmt.Println("couldn't connect to the cluster, trying again..")
  11. return nil, err
  12. }
  13. remote, err := conn.Dial("tcp", addr.String())
  14. if err != nil {
  15. fmt.Println("couldn't connect to the mongodb server:", addr.String())
  16. }
  17. return remote, err
  18. },
  19. }
  20. session, err = mgo.DialWithInfo(dialinfo)
  21.  
  22. dialinfo := mgo.DialInfo{
  23. Addrs: {"mongodbserver1","mongodbserver2"}
  24. Database: Mongo1,
  25. Username: User,
  26. Password: Pwd,
  27. Timeout: 60 * time.Second,
  28. DialServer: func(addr *mgo.ServerAddr) (net.Conn, error) {
  29. conn, err := connectToCluster("172.12.13.145")
  30. if err != nil {
  31. fmt.Println("couldn't connect to the cluster, trying again..")
  32. return nil, err
  33. }
  34. remote, err := conn.Dial("tcp", addr.String())
  35. if err != nil {
  36. fmt.Println("couldn't connect to the mongodb server:", addr.String())
  37. }
  38. return remote, err
  39. },
  40. }
  41. session, err = mgo.DialWithInfo(dialinfo)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement