Hello, list.

I've encountered a problem with generated Go code, namely, when I try
to use the same client to send multiple requests in quick succession I
run into "ping failed: out of sequence response" error.  This happens
because responses don't necessarily arrive before next request is
sent.  However, the generated code seems to assume this shouldn't
happen.

Below is the simplified code for generic generated send/receive:

func send() {
    id++
    receive()
}

func receive() error {
    message := actuallyReceive()
    if message.id != id {
        return fmt.Errorf("Ids don't match")
    }
    return nil
}

Where this becomes problematic is when you have two or more
outstanding requests.  Obviously, the id counter will miss some
responses, because it will be incremented before receive() was able to
process the previously sent message.

So, my questions are: is this behavior expected?  And if so, what's
the suggested way to have multiple outstanding requests?

Best.

Oleg

Reply via email to