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

Latency recording per node experiment #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
4 changes: 3 additions & 1 deletion channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type response struct {

type responseRouter struct {
c chan<- response
ts time.Time
streaming bool
}

Expand Down Expand Up @@ -81,6 +82,7 @@ func (c *channel) routeResponse(msgID uint64, resp response) {
c.responseMut.Lock()
defer c.responseMut.Unlock()
if router, ok := c.responseRouters[msgID]; ok {
c.latency = time.Since(router.ts)
router.c <- resp
// delete the router if we are only expecting a single message
if !router.streaming {
Expand All @@ -92,7 +94,7 @@ func (c *channel) routeResponse(msgID uint64, resp response) {
func (c *channel) enqueue(req request, responseChan chan<- response, streaming bool) {
if responseChan != nil {
c.responseMut.Lock()
c.responseRouters[req.msg.Metadata.MessageID] = responseRouter{responseChan, streaming}
c.responseRouters[req.msg.Metadata.MessageID] = responseRouter{responseChan, time.Now(), streaming}
c.responseMut.Unlock()
}
c.sendQ <- req
Expand Down
Loading