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

Add IPC Transport #424

Merged
merged 7 commits into from
Dec 16, 2020
Merged

Add IPC Transport #424

merged 7 commits into from
Dec 16, 2020

Conversation

lsunsi
Copy link
Contributor

@lsunsi lsunsi commented Dec 15, 2020

Regarding this issue: #415

This PR does not close it yet, because it doesn't add the duplex and batch transports.
But it's a start.

Copy link
Owner

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Thank you, looks good! Would be nice to have some docs and tests.

};

for output in outputs {
let id = match &output {
Copy link
Owner

Choose a reason for hiding this comment

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

This could simply be let id = output.id().clone()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in 93d190f

src/transports/ipc.rs Show resolved Hide resolved
}
}
}
Err(err) => log::warn!("Got bad IPC response bytes: {:?}", err),
Copy link
Owner

Choose a reason for hiding this comment

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

Should it really be a warn? What if we simply didn't get a full response yet (but it does have } or ])?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in 6a28cad

Comment on lines 131 to 141
let value = match helpers::to_result_from_output(output) {
Ok(value) => value,
Err(err) => {
log::warn!("Unable to parse output into rpc::Value: {:?}", err);
continue;
},
Copy link
Owner

Choose a reason for hiding this comment

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

If you extract to a function this would become

Suggested change
let value = match helpers::to_result_from_output(output) {
Ok(value) => value,
Err(err) => {
log::warn!("Unable to parse output into rpc::Value: {:?}", err);
continue;
},
let value = helpers::to_result_from_output(output)
.map_err(|err| log::warn!("Unable to parse output into rpc::Value: {:?}", err))?;

which imho looks much nicer

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in 7f34638

},
Some(Err(err)) => {
log::error!("IPC read error: {:?}", err);
break;
Copy link
Owner

Choose a reason for hiding this comment

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

Should this be return Err(...) instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in e3d3469

log::error!("IPC read error: {:?}", err);
break;
},
None => break,
Copy link
Owner

Choose a reason for hiding this comment

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

I'd change this to return Ok(()) and make the whole loop the last statement in the function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in e3d3469

src/transports/mod.rs Show resolved Hide resolved

loop {
tokio::select! {
message = messages_rx.next() => match message {
Copy link
Owner

Choose a reason for hiding this comment

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

The match here could be if let Some(message) = message {...}

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in 1788be6

@lsunsi
Copy link
Contributor Author

lsunsi commented Dec 15, 2020

@tomusdrw Thanks for the review! We're finishing up with the doc and tests, along with adding all the cfg flags. Then we'll take a look at your comments (and remove the draft flag). Be right back!

@lsunsi
Copy link
Contributor Author

lsunsi commented Dec 15, 2020

@tomusdrw Done deal! All comments replied. We sent fixups in order to make your re-review easier, but we'll squash all commits into one if everything is fine. Just let us know.

@lsunsi lsunsi marked this pull request as ready for review December 16, 2020 08:47
Copy link
Owner

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

Looks perfect, thank you so much! I squash PR commits before merge anyway, so need to squash manually.

@tomusdrw tomusdrw merged commit 78b405b into tomusdrw:master Dec 16, 2020
@lsunsi lsunsi deleted the add-ipc-transport branch December 16, 2020 10:07
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.

3 participants