ttrpc: use odd numbers for client initiated streams
Following the convention of http2, we now use odd stream ids for client initiated streams. This makes it easier to tell who initiates the stream. We enforce the convention on the server-side. This allows us to upgrade the protocol in the future to have server initiated streams. Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -27,6 +27,7 @@ type Client struct {
|
||||
func NewClient(conn net.Conn) *Client {
|
||||
c := &Client{
|
||||
codec: codec{},
|
||||
requestID: 1,
|
||||
channel: newChannel(conn, conn),
|
||||
sendRequests: make(chan sendRequest),
|
||||
recvRequests: make(chan recvRequest),
|
||||
@@ -44,7 +45,7 @@ func (c *Client) Call(ctx context.Context, service, method string, req, resp int
|
||||
return err
|
||||
}
|
||||
|
||||
requestID := atomic.AddUint32(&c.requestID, 1)
|
||||
requestID := atomic.AddUint32(&c.requestID, 2)
|
||||
request := Request{
|
||||
Service: service,
|
||||
Method: method,
|
||||
|
||||
Reference in New Issue
Block a user