Add a backend for co-processes #4

Open
opened 2020-10-13 22:37:03 +02:00 by p · 1 comment
Owner

The invocation can be as follows: json-rpc-shell --exec -- gopls serve

Use an AF_UNIX SOCK_STREAM socketpair(2) to communicate with the child. Redirect stderr to a pipe and display data from there in a controlled fashion so that it doesn't disrupt normal operation. Silencing stderr can be done externally by wrapping the command like sh -c "gopls serve 2>/dev/null" if needed, therefore a command line switch for that situation isn't necessary.

Since this feature targets the Language Server Protocol and the standard employs RFC 5322-like "Internet Message Format" headers, this is what we'll do as well. Unlike with WebSockets, there are no natural message boundaries and LSP servers are unlikely to support datagrams. The http-parser library can be re-used for this purpose.

We'll see how much software will work with a Content-Type of application/json; charset=utf-8, as opposed to LSP's application/vscode-jsonrpc; charset=utf-8.

The invocation can be as follows: `json-rpc-shell --exec -- gopls serve` Use an `AF_UNIX` `SOCK_STREAM` socketpair(2) to communicate with the child. Redirect stderr to a pipe and display data from there in a controlled fashion so that it doesn't disrupt normal operation. Silencing stderr can be done externally by wrapping the command like `sh -c "gopls serve 2>/dev/null"` if needed, therefore a command line switch for that situation isn't necessary. Since this feature targets the Language Server Protocol and the standard employs RFC 5322-like "Internet Message Format" headers, this is what we'll do as well. Unlike with WebSockets, there are no natural message boundaries and LSP servers are unlikely to support datagrams. The http-parser library can be re-used for this purpose. We'll see how much software will work with a Content-Type of `application/json; charset=utf-8`, as opposed to LSP's `application/vscode-jsonrpc; charset=utf-8`.
p self-assigned this 2020-10-13 22:37:03 +02:00
p added a new dependency 2020-10-13 22:40:34 +02:00
p added this to the v1.2.0 milestone 2020-10-13 22:47:18 +02:00
Author
Owner

Apparently Content-Type doesn't matter much. We've thrown a full HTTP parser at the protocol, pausing it between requests so that we can inject an HTTP/1.1 POST header line--it turns out the default of Connection: keep-alive is sometimes even convenient. Now blocking solely on adding bi-directionality.

Apparently Content-Type doesn't matter much. We've thrown a full HTTP parser at the protocol, pausing it between requests so that we can inject an HTTP/1.1 POST header line--it turns out the default of `Connection: keep-alive` is sometimes even convenient. Now blocking solely on adding bi-directionality.
p added the
WIP
label 2020-10-27 11:28:35 +01:00
p added this to the v1.2.0 project 2021-01-01 18:11:30 +01:00
Sign in to join this conversation.
No Label
WIP
easy
priority
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Depends on
Reference: p/json-rpc-shell#4
No description provided.