Skip to content

Commit

Permalink
feat: bump go.mongodb.org/mongo-driver from 1.0.4 to 1.1.0 (#10)
Browse files Browse the repository at this point in the history
feat: bump go.mongodb.org/mongo-driver from 1.0.4 to 1.1.0
  • Loading branch information
amorist authored Aug 15, 2019
2 parents d8d74f4 + 1ebe1d0 commit cfcafe6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/tidwall/pretty v1.0.0 // indirect
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c // indirect
github.com/xdg/stringprep v1.0.0 // indirect
go.mongodb.org/mongo-driver v1.0.4
go.mongodb.org/mongo-driver v1.1.0
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/text v0.3.2 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c h1:u40Z8hqBAAQyv+vATcGgV
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0 h1:d9X0esnoa3dFsV0FG35rAT0RIhYFlPq7MiP+DW89La0=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
go.mongodb.org/mongo-driver v1.0.4 h1:bHxbjH6iwh1uInchXadI6hQR107KEbgYsMzoblDONmQ=
go.mongodb.org/mongo-driver v1.0.4/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
go.mongodb.org/mongo-driver v1.1.0 h1:aeOqSrhl9eDRAap/3T5pCfMBEBxZ0vuXBP+RMtp2KX8=
go.mongodb.org/mongo-driver v1.1.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
Expand Down
18 changes: 15 additions & 3 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type Session struct {
client *mongo.Client
collection *mongo.Collection
maxPoolSize uint16
maxPoolSize uint64
db string
uri string
m sync.RWMutex
Expand Down Expand Up @@ -65,17 +65,29 @@ func (s *Session) Collection(collection string) *Collection {
}

// SetPoolLimit specifies the max size of a server's connection pool.
func (s *Session) SetPoolLimit(limit uint16) {
func (s *Session) SetPoolLimit(limit uint64) {
s.m.Lock()
s.maxPoolSize = limit
s.m.Unlock()
}

// Connect mongo client
func (s *Session) Connect() error {
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()
opt := options.Client().ApplyURI(s.uri)
opt.SetMaxPoolSize(s.maxPoolSize)
client, err := mongo.Connect(context.TODO(), opt)

client, err := mongo.NewClient(opt)
if err != nil {
return err
}

err = client.Connect(ctx)
if err != nil {
return err
}

if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestSession_Collection(t *testing.T) {

func TestSession_SetPoolLimit(t *testing.T) {
type args struct {
limit uint16
limit uint64
}
tests := []struct {
name string
Expand Down

0 comments on commit cfcafe6

Please sign in to comment.