Unverified Commit 08292b07 authored by Leonardo L's avatar Leonardo L Committed by GitHub
Browse files

refactor: update and turn `WsTransportClientBuilder` generic (#1168)



* refactor(jsonrpsee-client-transport): update and turn `WsTransportClientBuilder` generic

- fix(docs): typo on `WsTransportClientBuilder` doc on `Receiver`
  reference.
- refactor: add initial fn signatures for `build_with_stream`,
  `try_connect_over_tcp`, and `try_connect`.
- refactor: expose `EitherStream` visibility to public.
- refactor: make `Sender` and `Receiver` generic over T, a data stream.
- refactor: make `TransportSenderT` and `TransportReceiverT`
  implementations over generic `Sender` and `Receiver`, bound to
`AsyncRead`, `AsyncRead`, `MaybeSend` and `'static`.
- refactor: turn old `try_connect` TCP steps into
  `try_connect_over_tcp`.
- feat: implement `build_with_stream` and `try_connect` to handle and
  handle the handshake for a generic data stream `T`.
- feat: add new `Redirected` error variant to `WsHandshakeError`, as it
  should be handled by the client when using a generic data stream `T`.
- TODO(@oleonardolima): Add new tests that uses a different data stream.

* refactor(jsonrpsee-ws-client): add new fns to `WsClientBuilder`

- feat: add new `WsClientBuilder::build_with_transport` that builds and
  returns a `WsClient` with the given `Sender` and `Receiver`.
- feat: add new `WsClientBuilder::build_with_stream` that uses the new
  `WsTransportClientBuilder::build_with_stream`, building and returning
  the `WsClient` with the given `data_stream` as transport layer.
- refactor: update the `WsClientBuilder::build` to use the new
  `build_with_transport`, it helps not having duplicated code.

* refactor: re-export `EitherStream` & sort current list

* test: add integration tests and helper fns

- add new helper fns to spawn a socks5 server, using `fast-socks5`
- add new helper enum for `DataStream` that acts as a wrapper to
  `Socks5Stream<T>`, similar to what a client would need to do.
- impl AsyncRead + AsyncWrite for the helper `DataStream` enum, to make
  it compatible between futures::io and tokio::io.
- add new tests that connects over a socks5 proxy, and use the new
  `WsClientBuilder::default()::build_with_stream(...) fn.

* address review suggestions

---------

Co-authored-by: default avatarNiklas Adolfsson <[email protected]>
parent 3bcf42ee
Pipeline #416683 passed with stages
in 1 hour and 52 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment