kitex-contrib / codec-dubbo

支持 kitex <-> dubbo 互通的 dubbo 协议编解码器。
Apache License 2.0
16 stars 14 forks source link

Add option param to disable zookeeper keepalive #86

Closed s5364733 closed 5 months ago

s5364733 commented 5 months ago

Describe the bug

Existing logic, for zk SESSION persistence nodes will be continuously created for the same client. code show as below

func (z *zookeeperRegistry) keepalive(ctx context.Context, path string, content []byte) {
    sessionID := z.conn.SessionID()
    ticker := time.NewTicker(time.Second)
    defer ticker.Stop()
    for {
        select {
        case <-ctx.Done():
            return
        case <-ticker.C:
            cur := z.conn.SessionID()
            if cur != 0 && sessionID != cur {
                if err := z.createNode(path, content, true); err == nil {
                    sessionID = cur
                }
            }
        }
    }
}

In the development environment, if there is a problem with the registered machine itself, you may have to change the machine, or delete this option on zookeeper . This is not a very elegant way to deal with it. In addition, I understand that SESSION retention and SESSION disconnection and reconstruction are two things. concept

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Kitex version:

Please provide the version of Kitex you are using.

Environment:

The output of go env.

Additional context

Add any other context about the problem here.

DMwangnima commented 5 months ago

Refer to https://github.com/kitex-contrib/codec-dubbo/pull/87 for details.