mgop

package module
v0.0.0-...-be79741 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2017 License: MIT Imports: 6 Imported by: 0

README

mgop
GoDoc

a mgo session pool still need more work...

go get github.com/CardInfoLink/mgo
go get github.com/JodeZer/mgop

with mgo, client hosts may create too much connections by using Copy method in high concurrency situation,like this

func foo(){
  s := globalSession.Copy()
  defer s.Close()
}

especially when using mgo.Eventual mode.

mgop helps mongo doing better in high concurrency situation by buffering some sockets and tranporting requests through these sockets.

func foo(){
  p, _ := mgop.DialPool("127.0.0.1:27017", 5)
  session := p.AcquireSession()
  defer session.Release()
  session.DB("test").C("test").Insert(bson.M{"id":1})
}

more deatils seeing example folder

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionPool

type SessionPool interface {
	AcquireSession() *sessionWrapper
	Size() int
}

func DialStrongPool

func DialStrongPool(url string, fixedSize int) (SessionPool, error)

type StrongSessionPool

type StrongSessionPool struct {
	// contains filtered or unexported fields
}

func (*StrongSessionPool) AcquireSession

func (p *StrongSessionPool) AcquireSession() *sessionWrapper

func (*StrongSessionPool) Size

func (p *StrongSessionPool) Size() int

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL