zinx icon indicating copy to clipboard operation
zinx copied to clipboard

Request stepLock and Chain.Proceed

Open johnwayne19860314 opened this issue 1 year ago • 0 comments

func (r *Request) next() { if r.needNext == false { r.needNext = true return }

r.stepLock.Lock()
r.steps++
r.stepLock.Unlock()

}

request是每个conn读到一条消息就创建一条,并分配给唯一一个work处理,不太明白这里为什么要加锁,我的理解是request不会被多个goroutine 并发操作

func (c *Chain) Proceed(request ziface.IcReq) ziface.IcResp { if c.position < len(c.interceptors) { // why NewChain but not use the same chain chain := NewChain(c.interceptors, c.position+1, request) interceptor := c.interceptors[c.position] response := interceptor.Intercept(chain) return response } return request } not sure why NewChain is needed every time in Processed. why not just increment the position?

johnwayne19860314 avatar Dec 22 '23 12:12 johnwayne19860314