Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec struct {
Timeout time.Duration
Closer io.ReadWriteCloser
Decoder *gob.Decoder
Encoder *gob.Encoder
EncBuf *bufio.Writer
}
Codec ...
func (*Codec) ReadResponseBody ¶
ReadResponseBody ...
func (*Codec) ReadResponseHeader ¶
ReadResponseHeader ...
type Options ¶
type Options struct {
//InitTargets init targets
InitTargets []string
// init connection
InitCap int
// max connections
MaxCap int
DialTimeout time.Duration
IdleTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
// contains filtered or unexported fields
}
Options pool options
func NewOptions ¶
func NewOptions() *Options
NewOptions returns a new newOptions instance with sane defaults.
type RPCPool ¶
type RPCPool struct {
Mu sync.Mutex
IdleTimeout time.Duration
// contains filtered or unexported fields
}
RPCPool pool info
Example ¶
options := &Options{
InitTargets: []string{"127.0.0.1:8080"},
InitCap: 5,
MaxCap: 30,
DialTimeout: time.Second * 5,
IdleTimeout: time.Second * 60,
ReadTimeout: time.Second * 5,
WriteTimeout: time.Second * 5,
}
p, err := NewRPCPool(options)
if err != nil {
log.Printf("%#v\n", err)
return
}
if p == nil {
log.Printf("p= %#v\n", p)
return
}
defer p.Close()
//todo
//danamic update targets
//options.Input()<-&[]string{}
conn, err := p.Get()
if err != nil {
log.Printf("%#v\n", err)
return
}
defer p.Put(conn)
//todo
//conn.DoSomething()
log.Printf("len=%d\n", p.IdleCount())
type TCPPool ¶
type TCPPool struct {
Mu sync.Mutex
IdleTimeout time.Duration
// contains filtered or unexported fields
}
TCPPool pool info
Example ¶
options := &Options{
InitTargets: []string{"127.0.0.1:8080"},
InitCap: 5,
MaxCap: 30,
DialTimeout: time.Second * 5,
IdleTimeout: time.Second * 60,
ReadTimeout: time.Second * 5,
WriteTimeout: time.Second * 5,
}
p, err := NewTCPPool(options)
if err != nil {
log.Printf("%#v\n", err)
return
}
if p == nil {
log.Printf("p= %#v\n", p)
return
}
defer p.Close()
//todo
//danamic update targets
//options.Input()<-&[]string{}
conn, err := p.Get()
if err != nil {
log.Printf("%#v\n", err)
return
}
defer p.Put(conn)
//todo
//conn.DoSomething()
log.Printf("len=%d\n", p.IdleCount())
Click to show internal directories.
Click to hide internal directories.