Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,20 @@ func (c *channelPool) Get() (interface{}, error) {
}
return wrapConn.conn, nil
default:
conn, err := c.factory()
if err != nil {
return nil, err
}

return conn, nil
return c.Connect()
}
}
}

//Conn 重新创建一个连接

@silenceper silenceper Sep 23, 2018

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

golint: Connect

func (c *channelPool) Connect() (interface{}, error) {
conn, err := c.factory()
if err != nil {
return nil, err
}
return conn, nil
}

//Put 将连接放回pool中
func (c *channelPool) Put(conn interface{}) error {
if conn == nil {
Expand Down
2 changes: 2 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var (
type Pool interface {
Get() (interface{}, error)

Connect() (interface{}, error)

Put(interface{}) error

Close(interface{}) error
Expand Down