Skip to content

Commit

Permalink
fix(mongodb): change mongodb session mode to fix session closed expli…
Browse files Browse the repository at this point in the history
…citly (#272)
  • Loading branch information
supereagle committed Nov 29, 2017
1 parent 3533cf6 commit c307e9e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func Init(host string, gracePeriod time.Duration, closing chan struct{}) (*mgo.S
}

log.Infof("connect to mongodb addr: %s", host)
session.SetMode(mgo.Strong, true)
// Set the session mode as Eventual to ensure that the socket is created for each request.
// Can switch to other mode only after the old APIs are cleaned up.
session.SetMode(mgo.Eventual, true)

go backgroundMongo(closing)

Expand Down

0 comments on commit c307e9e

Please sign in to comment.