Migrate JSON-RPC layer to gumeniukcom/golang-jsonrpc2 - #170
Open
gumeniukcom wants to merge 1 commit into
Open
Conversation
Replaces creachadair/jrpc2 with github.com/gumeniukcom/golang-jsonrpc2/v2 (jsonrpcstdio transport + typed method registration). The Assigner switch becomes declarative RegisterTyped calls; each handler drops its HasParams/UnmarshalParams boilerplate and takes typed params directly. publishDiagnostics pushes through the transport's per-connection Pusher from the request context instead of a stored *jrpc2.Server, so the SetServer wiring disappears. Parity kept: Content-Length framing (channel.LSP equivalent), all 17 methods with identical names and param types, shutdown's null result, notification silence, clean-EOF lifecycle, server push. Dispatch is now strictly sequential and in-order (the transport default) — stronger than jrpc2's notification barrier and what LSP ordering assumes; a generous 15-minute per-request bound replaces jrpc2's absence of one (the library defaults to 30s, too tight for the first didOpen's dagger session). Behavior notes: handler error texts stay in server logs (clients receive stable generic codes; formatting's document-not-found keeps -32602 via RPCError), wire-level trace logging is replaced by handler-error logging, and handler panics are now recovered and answered instead of crashing. Tests migrated to drive the new dispatcher in-process with a test Pusher; all assertions unchanged. Verified against a live LSP session (initialize/didOpen with publishDiagnostics push/hover/shutdown).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #169
Follow-up to #169 — promoting the migration branch to a PR so it's easier to review. Happy to adjust anything.
Summary
Replaces
creachadair/jrpc2withgithub.com/gumeniukcom/golang-jsonrpc2/v2+ itsjsonrpcstdiotransport. Net effect: −305/+176 lines across 22 files — the migration shrinks the code.cmd/dang/main.go:jrpc2.NewServer/channel.LSP/stdrwc→jsonrpcstdio.Serve(ctx, rpc, FramingContentLength, os.Stdin, os.Stdout).pkg/lsp/handler.go: theAssignermap → declarativeRegister(rpc)with 17RegisterTypedregistrations; eachhandle_*.gogets typed params instead ofreq.UnmarshalParamsboilerplate.publishDiagnosticsgoes through the transport'sPushertaken from the request context — theserverback-reference field andSetServerwiring are deleted entirely.Semantics notes
didChangefully applied before a subsequenthover) are preserved.didOpenin a project can legitimately take a while (dagger session + schema introspection), and jrpc2 had no timeout at all.Test plan
go test ./...passestextDocument/publishDiagnosticspush on the wire → hover → shutdown, responses in order, exit 0)