зеркало из https://github.com/golang/tools.git
a199121ba9
As described in golang/go#69937, we need a mechanism that allows for concurrent request handling in gopls. However, this cannot be implemented entirely within the jsonrpc2 layer, because we need gopls to observe requests in the order they arrive, so it can handle them with the correct logical state. This CL adds such a concurrency mechanism using a trick similar to t.Parallel. Specifically, a new jsonrpc2.Async method is introduced which, when invoked on the request context, signals the jsonrpc2.AsyncHandler to start handling the next request. Initially, we use this new mechanism within gopls to allow certain long-running commands to execute asynchronously, once they have acquired a cache.Snapshot representing the current logical state. This solves a long-standing awkwardness in the govulncheck integration, which required an additional gopls.fetch_vulncheck_result command to fetch an asynchronous result. This enables some code deletion and simplification, though we could simplify further. Notably, change the code_action subcommand to eliminate the progress handler registration, since we don't need progress to know when a command is complete. Instead, use -v as a signal to log progress reports to stderr. Fixes golang/go#69937 Change-Id: I8736a445084cfa093f37c479d419294d5a1acbce Reviewed-on: https://go-review.googlesource.com/c/tools/+/621055 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> |
||
---|---|---|
.. | ||
servertest | ||
conn.go | ||
handler.go | ||
jsonrpc2.go | ||
jsonrpc2_test.go | ||
labels.go | ||
messages.go | ||
serve.go | ||
serve_test.go | ||
stream.go | ||
wire.go | ||
wire_test.go |