getOrCreateExchange returns the exchange for requestID, allocating one if it does not yet exist. The runtime dispatches httpRequestStart and httpRequestChunk frames on separate goroutines (see jsonrpc2.handleRequest), so a body chunk — including the terminal end frame — can arrive before its start f
(requestID string)
| 568 | // first touch means those chunks are buffered rather than dropped, instead of |
| 569 | // hanging the body drain forever. |
| 570 | func (a *copilotRequestAdapter) getOrCreateExchange(requestID string) *pendingExchange { |
| 571 | a.mu.Lock() |
| 572 | defer a.mu.Unlock() |
| 573 | if exchange, ok := a.pending[requestID]; ok { |
| 574 | return exchange |
| 575 | } |
| 576 | ctx, cancel := context.WithCancel(context.Background()) |
| 577 | exchange := &pendingExchange{queue: newFrameQueue(), ctx: ctx, cancel: cancel} |
| 578 | a.pending[requestID] = exchange |
| 579 | return exchange |
| 580 | } |
| 581 | |
| 582 | func (a *copilotRequestAdapter) HttpRequestStart(params *rpc.LlmInferenceHTTPRequestStartRequest) (*rpc.LlmInferenceHTTPRequestStartResult, error) { |
| 583 | // Adopt any exchange a racing chunk already created — with its buffered |
no test coverage detected