tools/internal/jsonrpc2
Rob Findley a199121ba9 gopls: allow for asynchronous request handling
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>
2024-10-18 20:45:24 +00:00
..
servertest gopls/internal/regtest/bench: refactor and improve benchmarks 2022-08-04 14:58:59 +00:00
conn.go gopls: normalize logging attributes 2024-04-26 20:08:17 +00:00
handler.go gopls: allow for asynchronous request handling 2024-10-18 20:45:24 +00:00
jsonrpc2.go
jsonrpc2_test.go
labels.go gopls: normalize logging attributes 2024-04-26 20:08:17 +00:00
messages.go internal/jsonrpc2: export WireError type 2024-02-07 19:42:43 +00:00
serve.go all: use constant to avoid repeated definitions 2022-09-19 15:32:23 +00:00
serve_test.go all: fix non-gopls short tests on js/wasm and update for wasip1/wasm 2023-04-20 14:27:21 +00:00
stream.go
wire.go internal/jsonrpc2: export WireError type 2024-02-07 19:42:43 +00:00
wire_test.go