Skip to content

[ws-server] Batch support#300

Merged
dvdplm merged 15 commits into
masterfrom
dp-batch-support-ws
May 7, 2021
Merged

[ws-server] Batch support#300
dvdplm merged 15 commits into
masterfrom
dp-batch-support-ws

Conversation

@dvdplm
Copy link
Copy Markdown
Contributor

@dvdplm dvdplm commented May 4, 2021

Add batch request support for the websocket server. Continuation of #292.

Closes #277

TODO:

  • better tests
  • sort out error, switch from InvalidParams to CallError::Failed
  • benchmarks

Comment thread http-server/src/module.rs Outdated
Comment thread test-utils/src/types.rs Outdated
Comment thread utils/src/server.rs Outdated
Comment thread http-server/src/module.rs Outdated
Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
Comment thread ws-server/src/server.rs
Comment thread ws-server/src/server.rs Outdated
Comment thread ws-server/src/server.rs Outdated
Comment thread ws-server/src/server/module.rs Outdated
Ok(res) => send_response(id, tx, res),
Err(InvalidParams) => send_error(id, tx, JsonRpcErrorCode::InvalidParams.into()),
// TODO: this looks wonky...
Err(CallError::InvalidParams(InvalidParams)) => {
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Comment thread ws-server/src/server/module.rs Outdated
Comment thread ws-server/src/tests.rs
Copy link
Copy Markdown
Contributor

@niklasad1 niklasad1 left a 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.

@niklasad1
Copy link
Copy Markdown
Contributor

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
@dvdplm dvdplm marked this pull request as ready for review May 6, 2021 10:34
@dvdplm dvdplm requested a review from insipx May 6, 2021 12:15
@dvdplm dvdplm self-assigned this May 6, 2021
Copy link
Copy Markdown
Contributor

@insipx insipx left a 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 👍

Comment thread ws-server/src/server.rs Outdated
Comment thread ws-server/src/server.rs Outdated
dvdplm and others added 2 commits May 7, 2021 12:38
Co-authored-by: Andrew Plaza <aplaza@liquidthink.net>
Co-authored-by: Andrew Plaza <aplaza@liquidthink.net>
@dvdplm dvdplm merged commit 4038e9e into master May 7, 2021
@dvdplm dvdplm deleted the dp-batch-support-ws branch May 7, 2021 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[servers]: batch request support

3 participants