removed debug msg
This commit is contained in:
parent
6a7a6135da
commit
f8f8cb2366
7
mgo.go
7
mgo.go
@ -2,7 +2,6 @@ package mgocrud
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
mgo "gopkg.in/mgo.v2"
|
||||
@ -14,7 +13,6 @@ type MgoConnection struct {
|
||||
}
|
||||
|
||||
func NewMgoConnection(dial string) (Connection, error) {
|
||||
fmt.Println("CONNECTION CREATE")
|
||||
connection, err := mgo.Dial(dial)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -22,7 +20,6 @@ func NewMgoConnection(dial string) (Connection, error) {
|
||||
connection.SetMode(mgo.Monotonic, true)
|
||||
c := &MgoConnection{connection: connection}
|
||||
runtime.SetFinalizer(c, func(c *MgoConnection) {
|
||||
fmt.Println("CONNECTION CLOSE FINALIZER")
|
||||
if !c.closed {
|
||||
c.Close()
|
||||
}
|
||||
@ -31,7 +28,6 @@ func NewMgoConnection(dial string) (Connection, error) {
|
||||
}
|
||||
|
||||
func (c *MgoConnection) Close() {
|
||||
fmt.Println("CONNECTION CLOSE MANUALLY")
|
||||
if !c.closed {
|
||||
c.connection.Close()
|
||||
c.closed = true
|
||||
@ -45,7 +41,6 @@ type MgoSession struct {
|
||||
}
|
||||
|
||||
func (s *MgoSession) Close() {
|
||||
fmt.Println("SESSION CLOSE MANUALLY")
|
||||
if !s.closed {
|
||||
s.session.Close()
|
||||
s.closed = true
|
||||
@ -54,10 +49,8 @@ func (s *MgoSession) Close() {
|
||||
}
|
||||
|
||||
func (c *MgoConnection) NewSession() Session {
|
||||
fmt.Println("SESSION CREATE")
|
||||
s := &MgoSession{session: c.connection.Copy()}
|
||||
runtime.SetFinalizer(s, func(s *MgoSession) {
|
||||
fmt.Println("SESSION CLOSE FINALIZER")
|
||||
if !s.closed {
|
||||
s.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user