Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check connection count #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add check connection count #4

wants to merge 1 commit into from

Conversation

xinliangnote
Copy link

  1. 当初始化的链接都超过了空闲时间,当 pool.Get 时,会重新创建一个链接并返回。
    针对这个问题,新增了一个方法,在 NewGRPCPool 方法中调用,每隔 10s 中,维护一下连接池数量。
//check connection count
go pool.CheckGRPCPool()
  1. 当初始化的链接数超过 MaxCap,比如做压测的时候。
    针对这个问题,新增了一个判断,当 c.IdleCount() >= MaxCap 时,会返回一个 Error。

  2. pool.Get 时,新增一个判断:

if wrapConn.conn.GetState() != connectivity.Ready {
	c.close(wrapConn.conn)
	continue
}

add := c.minConns - len(c.conns)
for i := 0; i < add; i++ {
conn, _ := c.factory()
c.Put(conn)

Choose a reason for hiding this comment

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

Error return value of c.Put is not checked (from errcheck)

Repository owner deleted a comment Feb 2, 2024
Repository owner deleted a comment from SASECOMPANY Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants