Skip to content

Commit 87685e6

Browse files
committed
remove legacy code
1 parent a019ca1 commit 87685e6

18 files changed

+197
-1193
lines changed

.travis.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ before_install:
1818
- export MONGO_TEST=mongodb://127.0.0.1:27017
1919

2020
script:
21-
- GO111MODULE=on go get ./...
22-
- GO111MODULE=on go mod vendor
23-
- GO111MODULE=on go test -v -mod=vendor -covermode=count -coverprofile=profile.cov ./... || travis_terminate 1;
24-
- GO111MODULE=on go test -v -covermode=count -coverprofile=profile.cov ./... || travis_terminate 1;
21+
- export GO111MODULE=on
22+
- go get ./...
23+
- go test -v -covermode=count -coverprofile=profile.cov ./... || travis_terminate 1;
2524
- golangci-lint run || travis_terminate 1;
2625
- $GOPATH/bin/goveralls -coverprofile=profile.cov -service=travis-ci

README.md

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Mongo [![Build Status](https://travis-ci.org/go-pkgz/mongo.svg?branch=master)](https://travis-ci.org/go-pkgz/mongo) [![Go Report Card](https://goreportcard.com/badge/github.com/go-pkgz/mongo)](https://goreportcard.com/report/github.com/go-pkgz/mongo) [![Coverage Status](https://coveralls.io/repos/github/go-pkgz/mongo/badge.svg?branch=master)](https://coveralls.io/github/go-pkgz/mongo?branch=master)
22

3-
Provides helpers on top of [mgo](https://github.com/globalsign/mgo) and the official [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
3+
Provides helpers on top of [mongo-go-driver](https://github.com/mongodb/mongo-go-driver)
44

55
## Version 2, with the official mongo-go-driver
66

@@ -26,49 +26,3 @@ Provides helpers on top of [mgo](https://github.com/globalsign/mgo) and the offi
2626
`mongo.MakeTestConnection` creates `mongo.Client` and `mongo.Collection` for url defined in env `MONGO_TEST`.
2727
If not defined`mongodb://mongo:27017` used. By default it will use random connection with prefix `test_` in `test` DB.
2828

29-
30-
## Legacy version, with mgo
31-
32-
- Install and update - `go get -u github.com/go-pkgz/mongo`
33-
34-
- `Server` represents mongo instance and provides session accessor. Application usually creates one server object and uses it for anything needed with this particular mongo host or replica set.
35-
36-
- `Connection` encapsulates session and provides auto-closable wrapper. Each requests runs inside one of With* function makes new mongo session and closes on completion.
37-
38-
- `BufferedWriter` implements buffered writer to mongo. Write method caching internally till it reached buffer size. Flush methods can be called manually at any time.
39-
40-
41-
```golang
42-
m, err := NewServerWithURL("mongodb://127.0.0.1:27017/test?debug=true", 3*time.Second)
43-
if err != nil {
44-
panic("can't make mongo server")
45-
}
46-
47-
type testRecord struct {
48-
Key1 string
49-
Kay2 int
50-
}
51-
52-
err = c.WithCollection(func(coll *mgo.Collection) error { // create session
53-
// insert 100 records
54-
for i := 0; i < 100; i++ {
55-
r := testRecord{
56-
Key1: fmt.Sprintf("key-%02d", i%5),
57-
Key2: i,
58-
}
59-
if e := coll.Insert(r); e != nil {
60-
return e
61-
}
62-
}
63-
return nil
64-
})
65-
66-
```
67-
68-
### Testing
69-
70-
`testing.go` helps to create test for real mongo (not mocks)
71-
72-
- `mongo.MakeTestConnection` creates `mongo.Connection` for url defined in env `MONGO_TEST`. If not defined `mongodb://mongo:27017` used. By default it will use random connection with prefix `test_` in `test` DB.
73-
- `mongo.RemoveTestCollection` - drops collection used by `MakeTestConnection`
74-
- `mongo.RemoveTestCollections` - drops user-defined collections from `test` DB

connection.go

Lines changed: 0 additions & 67 deletions
This file was deleted.

connection_test.go

Lines changed: 0 additions & 190 deletions
This file was deleted.

go.mod

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
module github.com/go-pkgz/mongo
1+
module github.com/go-pkgz/mongo/v2
22

33
require (
44
github.com/davecgh/go-spew v1.1.1 // indirect
5-
github.com/globalsign/mgo v0.0.0-20180615134936-113d3961e731
65
github.com/go-pkgz/lgr v0.2.2
7-
github.com/kr/pretty v0.1.0 // indirect
6+
github.com/go-stack/stack v1.8.0 // indirect
7+
github.com/golang/snappy v0.0.1 // indirect
8+
github.com/google/go-cmp v0.3.1 // indirect
9+
github.com/pkg/errors v0.8.1
810
github.com/stretchr/testify v1.3.0
9-
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
11+
github.com/tidwall/pretty v1.0.0 // indirect
12+
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
13+
github.com/xdg/stringprep v1.0.0 // indirect
14+
go.mongodb.org/mongo-driver v1.1.1
15+
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
16+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
17+
golang.org/x/text v0.3.2 // indirect
1018
)
1119

1220
go 1.13

0 commit comments

Comments
 (0)