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

58 commits

Author SHA1 Message Date
sourcegraph-bot
e58a7f5b4f
Merge 01ce4c18a2 into c9c77b6bb9 2021-11-20 07:06:28 +00:00
Sam Herrmann
c9c77b6bb9
Add ability to set custom logger (#48)
Before this commit, a custom logger could be set with the LogMessages
function. However, by using LogMessages not only is a custom logger set
but also all received and sent messages are logged. Use cases exist
where a custom logger is desired to log errors but not all messages.
2021-11-19 10:30:03 +02:00
lhchavez
5f298fe6a1
Homogenize treatment of params and meta in UnmarshalJSON (#52)
This change makes the treatment of params and meta the same, by
assigning a well-known pointer at first to detect if the unmarshaling
process overwrites it with an explicit nil, or it stays the same in
which it means that it was unset from the beginning.
2021-08-04 18:55:02 +02:00
lhchavez
120d461fd1
Add GitHub actions (#51)
That extra green checkmark does wonders for peace of mind.
2021-08-04 14:46:32 +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
amyxia
5cdc7d6ccd
fix typo in jsonrpc2/stream.go (#47)
Co-authored-by: xiarui.xr <xiarui.xr@antfin.com>
2021-05-26 14:52:51 +02:00
Sam Herrmann
99f63e011f
Add PlainObjectCodec (#45) 2021-04-26 09:13:34 +02:00
Sam Herrmann
08fd77d0de
Add StringID call option (#44)
Fixes #43
2021-04-26 09:12:26 +02:00
Cornelius Weig
366fbb5207
Break the Call method into a dispatcher and waiter (#41)
Before, the Call method dispatched the JSON-RPC request and waited
until completion of the request before returning. This made it difficult
to release any locks that need to be released upon dispatch.

Now, the Call method is broken into a DispatchCall and Wait pair.
DispatchCall returns a proxy to the internal call object as soon as the
request is dispatched. When appropriate, the caller can invoke the Wait
method on this proxy to block until the result is ready.

The original Call method is not changed, but now implemented by
these primitives.
2021-02-01 10:28:50 +02:00
garo (they/them)
15c2290dcb
update LSIF indexing CI workflow 2020-04-29 14:40:54 -04:00
Sourcegraph Bot
9e615b1c32 LSIF Indexing Campaign 2020-04-29 16:57:20 +00:00
Sourcegraph Bot
01ce4c18a2 Use t.Cleanup instead of defer in Golang code tests 2020-04-28 15:58:19 +00:00
Quinn Slack
96c4efab7e
Produce LSIF data for each commit for fast/precise code nav (#35)
* Produce LSIF data for each commit for fast/precise code nav

* Update lsif.yml
2019-12-21 20:34:38 -08:00
Quinn Slack
cee7209801
minor logging fixes (#34)
minor logging fixes
2019-11-13 00:00:33 -08:00
s3rj1k
81af42d766 minor logging fixes
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-07 23:44:16 +02:00
s3rj1k
3bf62ad25c fix Using a reference for the variable on range scope (#32)
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-04 13:57:41 -08:00
Quinn Slack
9d396041a5
Merge pull request #31 from s3rj1k/logger
use custom logger for internal logging
2019-11-03 21:31:32 -08:00
s3rj1k
76d435e06e support for go 1.12+ (#30) 2019-11-03 12:56:29 -08:00
s3rj1k
6053545ad1 use custom logger for internal logging
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-03 22:30:34 +02:00
s3rj1k
0f50d0d83e fix File is not goimports-ed (#28)
Signed-off-by: s3rj1k <evasive.gyron@gmail.com>
2019-11-03 11:41:16 -08:00
Quinn Slack
8819199291
fix some golangci-lint, revive linter warnings (#25)
fix some golangci-lint, revive linter warnings
2019-11-02 21:42:37 -07:00
Quinn Slack
375ca94e9c add go module, simplify some cleanups 2019-11-02 21:39:58 -07: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
Quinn Slack
35a74f039c
Merge pull request #23 from ggicci/master
Prevent program from panic on nil options
2019-01-06 12:59:02 -06:00
Ggicci
3e2e814648 fix: don't apply nil CallOption and ConnOpt 2019-01-07 01:47:28 +08:00
Sergey Mudrik
549eb959f0 Replaced log.Logger parameter by interface (#20) 2018-08-31 09:05:25 -07:00
Sergey Mudrik
073230af28 Use the last stable Go on Travis CI (#21) 2018-08-31 09:04:50 -07:00
Sergey Mudrik
aa573bdc2a Added link to the godoc reference (#19) 2018-08-22 01:37:14 -07:00
Keegan Carruthers-Smith
a3d86c792f allow multiple OnRecv and OnSend 2018-05-01 19:02:17 +01:00
Keegan Carruthers-Smith
2ed59d3304
remove content type from vscode object codec (#18) 2018-03-29 15:25:20 +02:00
Stephen Gutekanst
dbf20885e7
Merge pull request #17 from sourcegraph/sg/suppress
add support for suppressing ErrClosed in HandlerWithError logs
2018-02-12 18:08:19 -07:00
Stephen Gutekanst
c9e82539c3 add support for suppressing ErrClosed in HandlerWithError logs 2018-02-09 17:25:59 -07:00
Ondřej Kupka
c6c7b9aa99 Response: Add omitempty tag for Result (#14)
The 'result' key MUST be unset according when the error key is set.
This is not what is happening right now. When the error is set,
"result":null is returned in the response payload. This patch is fixing
the issue by adding omitempty for the result field.
2017-08-02 20:50:46 +02:00
Keegan Carruthers-Smith
b02337b177 typo in AsyncHandler docstring 2017-02-21 17:51:53 +02: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
277d2464cf ci: disable testing tip (#11)
It is failing the tests. This may actually be an underlying issue in the tests,
but not a big deal to fix now.
2017-02-20 04:55:33 -08:00
Keegan Carruthers-Smith
955f217b74 Add Meta field to Response (#10) 2017-02-20 14:21:08 +02:00
Quinn Slack
7ea7528660 add badge 2017-02-08 11:48:48 -08:00
Quinn Slack
0ad9fd8995 synchronize writes in BufferedObjectStream (#9)
Running various applications that use jsonrpc2 with the Go race detector shows that there is a race condition where `WriteObject` can be called from concurrent goroutines (e.g., 1 sending a request, 1 writing a response).
2017-01-31 23:39:03 -08:00
Keegan Carruthers-Smith
4f06164e9a Merge pull request #8 from sourcegraph/k/set-id
Add CallOpt SetID
2017-01-31 11:16:41 +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
cffa092597 better null handling in (Request).params and (Response).result (#7)
This makes the MarshalJSON/UnmarshalJSON methods centralize the logic, instead of requiring callers to occasionally munge responses to make them valid to later JSON-marshal.
2017-01-26 02:18:31 -08:00
Quinn Slack
6e88a787fb Merge pull request #6 from sourcegraph/explicit-null
support responses with null result ({"result":null})
2017-01-23 19:55:20 -08:00
Quinn Slack
64d0b93a7a propagate JSON "null" result instead of treating it as Go nil (and field-not-present in JSON) 2017-01-22 16:05:00 -08:00
Quinn Slack
a61d8f7bd7 warn when marshaling invalid Response 2017-01-22 15:45:18 -08:00
Quinn Slack
9edf388fe1 do not suppress error in TestAnyMessage 2017-01-22 15:34:24 -08:00
Quinn Slack
c0f3aff61f remove incorrect special handling of null results
It is not correct in general to convert null results in JSON-RPC 2.0 responses to `{}`.
2017-01-22 15:34:08 -08: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
Richard Musiol
9fdd802ab4
make call.done channel buffered so it can discard its value if the call got cancelled 2016-11-22 13:21:59 +01:00