1
0
Fork 0
mirror of https://github.com/sourcegraph/jsonrpc2.git synced 2026-06-16 04:04:56 +02:00
Commit graph

14 commits

Author SHA1 Message Date
Sam Herrmann
236b9e00cd Cleanup TestConn_DisconnectNotify
The purpose of this commit is to consolidate assertions that are
required for multiple tests related to `Conn.DisconnectNotify` into a
single function.
2023-02-06 17:47:04 -05:00
Sam Herrmann
21db451b57 Fix underlying connection not being closed on protocol error
Before this commit, the underlying connection of `Conn` was not being
closed when a protocol error was encountered. This behavior contradicted
with `Conn.DisconnectNotify()` because it reported that the underlying
connection was being closed. Additionally, the underlying connection was
now orphaned because `Conn` was no longer processing any of the
subsequent requests.

With this commit, the underlying connection is now being closed when a
protocol error is encountered, matching what `Conn.DisconnectNotify()`
has already been reporting.
2023-02-06 17:21:15 -05:00
Michał Nowotnik
a896fc3eac
[#57] Fix and deprecate PlainObjectCodec (#58)
This change fixes a bug that causes PlainObjectCodec to
lose additional messages from stream. json.Decoder has
an internal buffer that reads more than one message, but
is discarded after every use. Now PlainObjectCodec reuses
encoder and decoder within a buffered stream, however
using it directly in your code retains the old, incorrect
behaviour.

A user should now use plainObjectStream if he needs
plain JSON-RPC 2.0 stream without headers.
`NewPlainObjectStream` method has been added for this reason.
2022-07-11 15:43:39 +02:00
lhchavez
d6ac66e24f
Add a way to specify more non-standard-compliant fields to Request (#50)
This change introduces `ExtraField`, a `CallOption` that can add
arbitrary fields to the top-level JSON-RPC Request message.
2021-08-04 14:45:59 +02:00
Sam Herrmann
08fd77d0de
Add StringID call option (#44)
Fixes #43
2021-04-26 09:12:26 +02:00
s3rj1k
456318691a fix some golangci-lint, revive linter warnings
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-02 22:31:31 +02:00
Ggicci
3e2e814648 fix: don't apply nil CallOption and ConnOpt 2019-01-07 01:47:28 +08:00
Keegan Carruthers-Smith
3a7c446248 Handle is blocking (#12)
NOTE: This is a breaking change to the expected contract of Handler. Please update your implementation to use AsyncHandler if needs be.

We have strict ordering requirements of how we handle FileSystem requests in
LSP. As such relying on the ordering the goroutine scheduler runs requests in
leads to potential out of order mutations to the FS. As such we update the
jsonrpc2 implementation to by default block until Handle returns (note it can
still respond to the request at a later stage). For more simple use cases we
provide the AsyncHandler which will work like the previous implementation.

* Ensure handle is blocking
2017-02-21 14:25:50 +02:00
Keegan Carruthers-Smith
4fb7cd9079 Add CallOpt SetID
SetID allows a caller to control the ID of the request. Previously it was
impossible to set the ID of a call.
2017-01-31 11:08:53 +02:00
Quinn Slack
d58e8cc226 support responses with null result ({"result":null})
Previously, we incorrectly interpreted these as neither a request nor a response, and we printed an error for them. This is incorrect behavior per JSON-RPC 2.0 spec; responses can have a null result.
2017-01-22 15:34:05 -08:00
Quinn Slack
6e06d561ec Add pluggable transport interface + WebSocket support
simplify API by using interface{}, rename from transport -> stream

add WebSocket transport in websocket subpackage

do not buffer in ReadObject, rename GetObjectReader/ReadObject -> NextObjectReader

use xtest (jsonrpc2_test) package to allow us to test subpackages that depend on us (in a future change)

factor out vscode-specific transport code and allow pluggable transports

remove Server (unused) and Serve (unnecessary):
  The Serve func had nothing specific to JSON-RPC; it was just a loop
  around (net.Listener).Accept. It added no value.
2016-12-17 18:35:34 -08:00
Quinn Slack
6416f80f8f support string request IDs (in addition to numeric request IDs) 2016-11-06 07:12:05 -08:00
Quinn Slack
0328ebe20e remove incomplete JSON-RPC 2.0 batch support 2016-11-06 06:51:04 -08:00
Quinn Slack
c04eec1600 initial commit 2016-10-11 15:56:18 +02:00