Greetings,
I have goroutines that do Session.Copy() but checking mongos connection after launching my app, current connections rise up to 400~
mongos> db.serverStatus().connections
{ "current" : 4, "available" : 815, "totalCreated" : NumberLong(4) }
mongos> db.serverStatus().connections
{ "current" : 433, "available" : 386, "totalCreated" : NumberLong(433) }
mongos> db.serverStatus().connections
{ "current" : 417, "available" : 402, "totalCreated" : NumberLong(435) }
mongos>
this is the loop that launch the goroutines
wg.Add(len(topStoriesIds))
for _, id := range topStoriesIds {
go func(id int) {
newsContent := NewsReader(id)
ContentOutPut(newsContent, &wg)
}(id)
}
and the insert to mongodb logic from ContentOutPut
func HackerNewsInsert(n News, nTitle string, wg *sync.WaitGroup) {
defer wg.Done()
sc := SessionCopy()
defer sc.Close()
c := sc.DB(Db).C(NewsCollection)
if !NewsFindIfExist(nTitle, sc) {
return
}
err := c.Insert(n)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("saved! news!")
}
SessionCopy func
func SessionCopy() *mongodb.Session {
return MongodbSession.Copy()
}
what could be the problem? been doing this since yesterday and running in to few workarounds... thanks!