From 1847caa695c3f34a6be6d1de31f92d4518fb49c2 Mon Sep 17 00:00:00 2001 From: Jacky Date: Tue, 18 Jul 2017 19:00:20 +0800 Subject: [PATCH 1/2] refactor: move from gopkg.in/mgo.v2 to github.com/CardInfoLink/mgo --- .travis.yml | 2 +- auth.go | 4 ++-- auth_test.go | 2 +- bson/bson_test.go | 2 +- bson/decimal_test.go | 2 +- bson/json.go | 2 +- bson/json_test.go | 2 +- bulk.go | 2 +- bulk_test.go | 2 +- cluster.go | 2 +- cluster_test.go | 4 ++-- dbtest/dbserver.go | 2 +- dbtest/dbserver_test.go | 4 ++-- gridfs.go | 2 +- gridfs_test.go | 4 ++-- internal/scram/scram_test.go | 2 +- saslimpl.go | 2 +- server.go | 2 +- session.go | 2 +- session_test.go | 4 ++-- socket.go | 2 +- suite_test.go | 4 ++-- txn/debug.go | 2 +- txn/flusher.go | 4 ++-- txn/sim_test.go | 8 ++++---- txn/tarjan.go | 2 +- txn/tarjan_test.go | 2 +- txn/txn.go | 4 ++-- txn/txn_test.go | 8 ++++---- 29 files changed, 43 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index 45b38cf13..62f7a5ac6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: go -go_import_path: gopkg.in/mgo.v2 +go_import_path: github.com/CardInfoLink/mgo addons: apt: diff --git a/auth.go b/auth.go index dc26e52f5..7b1d42b5a 100644 --- a/auth.go +++ b/auth.go @@ -34,8 +34,8 @@ import ( "fmt" "sync" - "gopkg.in/mgo.v2/bson" - "gopkg.in/mgo.v2/internal/scram" + "github.com/CardInfoLink/mgo/bson" + "github.com/CardInfoLink/mgo/internal/scram" ) type authCmd struct { diff --git a/auth_test.go b/auth_test.go index 995273475..fe9efda74 100644 --- a/auth_test.go +++ b/auth_test.go @@ -39,7 +39,7 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" + "github.com/CardInfoLink/mgo" ) func (s *S) TestAuthLoginDatabase(c *C) { diff --git a/bson/bson_test.go b/bson/bson_test.go index 37451f9fd..16d58793c 100644 --- a/bson/bson_test.go +++ b/bson/bson_test.go @@ -40,7 +40,7 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" "gopkg.in/yaml.v2" ) diff --git a/bson/decimal_test.go b/bson/decimal_test.go index a29728094..ca97ee635 100644 --- a/bson/decimal_test.go +++ b/bson/decimal_test.go @@ -33,7 +33,7 @@ import ( "regexp" "strings" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" . "gopkg.in/check.v1" ) diff --git a/bson/json.go b/bson/json.go index 09df8260a..66644ed60 100644 --- a/bson/json.go +++ b/bson/json.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/base64" "fmt" - "gopkg.in/mgo.v2/internal/json" + "github.com/CardInfoLink/mgo/internal/json" "strconv" "time" ) diff --git a/bson/json_test.go b/bson/json_test.go index 866f51c34..db7fde38e 100644 --- a/bson/json_test.go +++ b/bson/json_test.go @@ -1,7 +1,7 @@ package bson_test import ( - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" . "gopkg.in/check.v1" "reflect" diff --git a/bulk.go b/bulk.go index 072a5206a..6b3a57ebe 100644 --- a/bulk.go +++ b/bulk.go @@ -4,7 +4,7 @@ import ( "bytes" "sort" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) // Bulk represents an operation that can be prepared with several diff --git a/bulk_test.go b/bulk_test.go index cb280bbfa..6fcec8a89 100644 --- a/bulk_test.go +++ b/bulk_test.go @@ -28,7 +28,7 @@ package mgo_test import ( . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" + "github.com/CardInfoLink/mgo" ) func (s *S) TestBulkInsert(c *C) { diff --git a/cluster.go b/cluster.go index c3bf8b013..4358f6e47 100644 --- a/cluster.go +++ b/cluster.go @@ -35,7 +35,7 @@ import ( "sync" "time" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) // --------------------------------------------------------------------------- diff --git a/cluster_test.go b/cluster_test.go index 54ec86762..00f9375d8 100644 --- a/cluster_test.go +++ b/cluster_test.go @@ -35,8 +35,8 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" ) func (s *S) TestNewSession(c *C) { diff --git a/dbtest/dbserver.go b/dbtest/dbserver.go index 16b7b5841..389a4adb6 100644 --- a/dbtest/dbserver.go +++ b/dbtest/dbserver.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "gopkg.in/mgo.v2" + "github.com/CardInfoLink/mgo" "gopkg.in/tomb.v2" ) diff --git a/dbtest/dbserver_test.go b/dbtest/dbserver_test.go index 79812fde3..d1c81e0a3 100644 --- a/dbtest/dbserver_test.go +++ b/dbtest/dbserver_test.go @@ -7,8 +7,8 @@ import ( . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/dbtest" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/dbtest" ) type M map[string]interface{} diff --git a/gridfs.go b/gridfs.go index 421472095..3384d8219 100644 --- a/gridfs.go +++ b/gridfs.go @@ -36,7 +36,7 @@ import ( "sync" "time" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) type GridFS struct { diff --git a/gridfs_test.go b/gridfs_test.go index 5a6ed5559..c60d91e0b 100644 --- a/gridfs_test.go +++ b/gridfs_test.go @@ -32,8 +32,8 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" ) func (s *S) TestGridFSCreate(c *C) { diff --git a/internal/scram/scram_test.go b/internal/scram/scram_test.go index 9c20fdfc4..73df35bb4 100644 --- a/internal/scram/scram_test.go +++ b/internal/scram/scram_test.go @@ -5,7 +5,7 @@ import ( "testing" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2/internal/scram" + "github.com/CardInfoLink/mgo/internal/scram" "strings" ) diff --git a/saslimpl.go b/saslimpl.go index 0d25f25cb..bc003e28b 100644 --- a/saslimpl.go +++ b/saslimpl.go @@ -3,7 +3,7 @@ package mgo import ( - "gopkg.in/mgo.v2/internal/sasl" + "github.com/CardInfoLink/mgo/internal/sasl" ) func saslNew(cred Credential, host string) (saslStepper, error) { diff --git a/server.go b/server.go index 392598691..06fd0c0f7 100644 --- a/server.go +++ b/server.go @@ -33,7 +33,7 @@ import ( "sync" "time" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) // --------------------------------------------------------------------------- diff --git a/session.go b/session.go index 3dccf364e..1b23fca4d 100644 --- a/session.go +++ b/session.go @@ -41,7 +41,7 @@ import ( "sync" "time" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) type Mode int diff --git a/session_test.go b/session_test.go index 492f21078..a8f842e64 100644 --- a/session_test.go +++ b/session_test.go @@ -38,8 +38,8 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" ) func (s *S) TestRunString(c *C) { diff --git a/socket.go b/socket.go index 8891dd5d7..d1eb17ad4 100644 --- a/socket.go +++ b/socket.go @@ -33,7 +33,7 @@ import ( "sync" "time" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) type replyFunc func(err error, reply *replyOp, docNum int, docData []byte) diff --git a/suite_test.go b/suite_test.go index bac5d3f4a..b885ae981 100644 --- a/suite_test.go +++ b/suite_test.go @@ -39,8 +39,8 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" ) var fast = flag.Bool("fast", false, "Skip slow tests") diff --git a/txn/debug.go b/txn/debug.go index 8224bb313..9e5da17c5 100644 --- a/txn/debug.go +++ b/txn/debug.go @@ -6,7 +6,7 @@ import ( "sort" "sync/atomic" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" ) var ( diff --git a/txn/flusher.go b/txn/flusher.go index f640a4380..0ed98f5e4 100644 --- a/txn/flusher.go +++ b/txn/flusher.go @@ -3,8 +3,8 @@ package txn import ( "fmt" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" ) func flush(r *Runner, t *transaction) error { diff --git a/txn/sim_test.go b/txn/sim_test.go index a369ded7c..bf55ecd1b 100644 --- a/txn/sim_test.go +++ b/txn/sim_test.go @@ -2,10 +2,10 @@ package txn_test import ( "flag" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" - "gopkg.in/mgo.v2/dbtest" - "gopkg.in/mgo.v2/txn" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" + "github.com/CardInfoLink/mgo/dbtest" + "github.com/CardInfoLink/mgo/txn" . "gopkg.in/check.v1" "math/rand" "time" diff --git a/txn/tarjan.go b/txn/tarjan.go index e56541c9b..2f04d73b6 100644 --- a/txn/tarjan.go +++ b/txn/tarjan.go @@ -1,7 +1,7 @@ package txn import ( - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" "sort" ) diff --git a/txn/tarjan_test.go b/txn/tarjan_test.go index 79745c39b..a27adc6b2 100644 --- a/txn/tarjan_test.go +++ b/txn/tarjan_test.go @@ -2,7 +2,7 @@ package txn import ( "fmt" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo/bson" . "gopkg.in/check.v1" ) diff --git a/txn/txn.go b/txn/txn.go index 204b3cf1d..55005f297 100644 --- a/txn/txn.go +++ b/txn/txn.go @@ -14,8 +14,8 @@ import ( "strings" "sync" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" crand "crypto/rand" mrand "math/rand" diff --git a/txn/txn_test.go b/txn/txn_test.go index 12923ca12..3283b720f 100644 --- a/txn/txn_test.go +++ b/txn/txn_test.go @@ -8,10 +8,10 @@ import ( "time" . "gopkg.in/check.v1" - "gopkg.in/mgo.v2" - "gopkg.in/mgo.v2/bson" - "gopkg.in/mgo.v2/dbtest" - "gopkg.in/mgo.v2/txn" + "github.com/CardInfoLink/mgo" + "github.com/CardInfoLink/mgo/bson" + "github.com/CardInfoLink/mgo/dbtest" + "github.com/CardInfoLink/mgo/txn" ) func TestAll(t *testing.T) { From 2cf0b2c20ed071beec6206641b533fa1c723d5ca Mon Sep 17 00:00:00 2001 From: Jacky Date: Tue, 18 Jul 2017 19:02:45 +0800 Subject: [PATCH 2/2] fix: reset server.abended state after successful isMaster call (https://github.com/go-mgo/mgo/pull/255) --- cluster.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cluster.go b/cluster.go index 4358f6e47..9b16c82eb 100644 --- a/cluster.go +++ b/cluster.go @@ -646,6 +646,10 @@ func (cluster *mongoCluster) AcquireSocket(mode Mode, slaveOk bool, syncTimeout cluster.syncServers() time.Sleep(100 * time.Millisecond) continue + } else { + server.Lock() + server.abended = false + server.Unlock() } } return s, nil