Skip to content
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

merge v2 to master #180

Merged
merged 63 commits into from
Jan 18, 2021
Merged

merge v2 to master #180

merged 63 commits into from
Jan 18, 2021

Conversation

niklasad1
Copy link
Member

No description provided.

This is temporary fix to work with the `server` which assumes that
`WebSocket` resonses are `text`
When the server receives an request with invalid JSON
`-32700, Parse error shall be returned`
`.await` was missing in RegisteredSubscription::send() and no responses
were actually sent which this commit fixes.
Hostname is required when using `wss` and `127.0.0.1` is not valid hostname.
Fixes newly introduced bug that causes `register_subscription` to have
side-effects even if the subscription fails.
* [ws server]: don't close conn. when `deser` fails

* Update src/ws/transport.rs

* grumbles: prefer matching of if else.
@yjhmelody
Copy link

LGTM.
I hope this PR can continue to advance because jsonrpc is better split into different crates. I just want to use jsonrpc's codec and various checks directly and don’t want to use the network part, but jsonrpc-core cannot be well integrated into some projects

async fn run_server(server_started_tx: Sender<()>, url: &str) {
let server = WsServer::new(url).await.unwrap();
let mut subscription =
server.register_subscription("subscribe_hello".to_string(), "unsubscribe_hello".to_string()).unwrap();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to rename this file to ws_subscription? Though http1.1 don't suppport subscription.

/// server automatically returns an "internal error" to the client.
///
/// Returns an error if the method name was already registered.
pub fn register_method(&self, method_name: String) -> Result<RegisteredMethod, Error> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether register_method should provide generic parameters, such as T: Into>. The same goes for some other similar methods


server_started_tx.send(()).unwrap();
loop {
let r = say_hello.next().await;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide a channel for each rpc method, I want to know if this programming model is reasonable

}

log::trace!("[frontend]: register_method={}", method_name);
let (tx, rx) = mpsc::channel(32);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether similar parameters should be configurable, I think this kind of parameters may affect performance and availability

@niklasad1
Copy link
Member Author

niklasad1 commented Jan 13, 2021

@yjhmelody

Thanks for reviewing, your comments are legit but I will not address them in this PR, the server implementations are under refactoring/on going work thus will likely change.

@niklasad1
Copy link
Member Author

//cc @dvdplm needs another review ^^

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.

5 participants