-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ws-server] Batch support #300
Conversation
Add a draft batch request test
Cleanup Use CallError
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
ws-server/src/server/module.rs
Outdated
@@ -47,7 +47,15 @@ impl RpcModule { | |||
Box::new(move |id, params, tx, _| { | |||
match callback(params) { | |||
Ok(res) => send_response(id, tx, res), | |||
Err(InvalidParams) => send_error(id, tx, JsonRpcErrorCode::InvalidParams.into()), | |||
// TODO: this looks wonky... | |||
Err(CallError::InvalidParams(InvalidParams)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this InvalidParams
type and just use to InvalidParams
variant,
perhaps link to #299
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thus, if CallError would implement a trait or something JsonRpcErrorCode
then you could just to err.to_error_code()
or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks overall good, not exactly sure of the overhead w.r.t spawning an unbounded channel per batch request.
Should be faster than reusing the existing channel and we "will" limit incoming requests based on payload size anyway so should be fine w.r.t OOM/DOS related issues.
An additional bonus to this PR, would be to add integration tests for batch requests (both HTTP and WS) Could address it in another PR also. |
Return app-level error when call fails
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than small nits 👍
Co-authored-by: Andrew Plaza <aplaza@liquidthink.net>
Co-authored-by: Andrew Plaza <aplaza@liquidthink.net>
Add batch request support for the websocket server. Continuation of #292.
Closes #277
TODO:
InvalidParams
toCallError::Failed