Skip to content
This repository has been archived by the owner on Dec 8, 2023. It is now read-only.

updated to recent tokio #37

Merged
merged 4 commits into from
May 17, 2019
Merged

updated to recent tokio #37

merged 4 commits into from
May 17, 2019

Conversation

ryankurte
Copy link
Contributor

@ryankurte ryankurte commented May 5, 2019

the PR updates tokio to 0.1.18 and hyper to 0.12.28, removing explicit Handles and altering calls as required, and refactors the Search module to handle multiple responses.

Copy link
Owner

@sbstp sbstp left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the PR. I just have a few comments and questions but overall it looks great.

str::from_utf8(&buf[..n])
.map_err(|err| SearchError::from(err))
.and_then(|text| parsing::parse_search_result(text))
.and_then(|text| {
println!("Recv: {:?}", text);
Copy link
Owner

Choose a reason for hiding this comment

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

Forgot a println here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, this library isn't working at all for me atm, so i'm trying to work out why :-/

should be removed, but also, if you have a working environment it'd be great to test.

Copy link
Owner

Choose a reason for hiding this comment

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

I've tested your branch on my local network and everything seemed to work fine. At what point is an issue occurring? Can it find the gateway? Is it an error while trying to add a port mapping?

The async example is kinda tricky because it uses a hard-coded IP address for the local machine which isn't going to work in 99% of the cases. I was planning on rewriting the example so it asks the IP address in the command args.

Copy link
Owner

Choose a reason for hiding this comment

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

I've changed the async example to improve it, you could try merging master in your branch and test it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

neat, i'll have a look tonight.

it seems my hue gateway responds first to the SDP request, with a payload that is considered invalid by the parser. have been wondering whether it'd be useful to move to ssdp for more general message parsing / encoding.

aside, it's probably also worth renaming the async bits now async is a keyword.

Copy link
Contributor Author

@ryankurte ryankurte May 7, 2019

Choose a reason for hiding this comment

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

ahh, that's useful. i re-wrote the async search module to handle multiple responses properly and simplifed the logic / API a bit, though still can't seem to convince my network to play ball to test it :-(

Copy link
Owner

Choose a reason for hiding this comment

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

Does the synchronous version of the library work well?

Copy link
Owner

Choose a reason for hiding this comment

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

It might also be due to timeouts, I think the default timeout is 3 seconds, so if your router is slower than that it will timeout before its response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahh it was a gateway misconfiguration, async stuff is working now ^_^

do you have any thoughts on the refactor? only thing that's not implemented is retries, but IMO that could be a separate PR.

Copy link
Owner

Choose a reason for hiding this comment

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

It's ok if retries aren't implemented just yet. I'll do a new review of the changes tomorrow (because it's 11 PM here) and test it out on my machine. I like what you did with SearchOptions and I'd probably add it to the synchronous version (if it's not done already).

You mentioned renaming the async module to something else, I think it makes sense because it will be a reserved keyword really soon. Not sure how to name it exactly, maybe tokio or aio.

examples/async.rs Show resolved Hide resolved
examples/async.rs Outdated Show resolved Hide resolved
src/async/gateway.rs Show resolved Hide resolved
hopefully it's clearer now too, still to integrate retries somehow
Copy link
Owner

@sbstp sbstp left a comment

Choose a reason for hiding this comment

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

Looks pretty good, just have a few nits. I can rename the module and change the synchronous code to use SearchOptions.

Cargo.toml Outdated Show resolved Hide resolved
src/async/search.rs Outdated Show resolved Hide resolved
src/async/search.rs Outdated Show resolved Hide resolved
src/async/search.rs Outdated Show resolved Hide resolved
src/async/soap.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@sbstp
Copy link
Owner

sbstp commented May 17, 2019

Oops sorry. I've been busy and I forgot about this.

@sbstp sbstp merged commit 64c8b5e into sbstp:master May 17, 2019
@sbstp
Copy link
Owner

sbstp commented May 17, 2019

Thanks a lot. I'm going to make the changes we discussed tomorrow and then release 0.9.

@sbstp
Copy link
Owner

sbstp commented May 19, 2019

It's out.

@ryankurte
Copy link
Contributor Author

neat, thanks!

@ryankurte
Copy link
Contributor Author

ryankurte commented May 22, 2019

i like how you've lifted SearchOptions, i wonder if it'd make sense to do the same with a RegisterOptions object and compress the register methods too.

as an aside, the Box<Future<_>> calls can also be replaced with impl Future as of 1.26.

@sbstp
Copy link
Owner

sbstp commented May 22, 2019

Do you mean the add_port and add_any_port methods on gateway? For now I'm happy with how they're setup.

The impl Future change would be nice, but for now it doesn't help our cause much since the returned type must be the same in conditional cases, so we'd have to keep the boxing anyway. It would just be syntaxic sugar.

@ryankurte
Copy link
Contributor Author

fair enough, and yeah, you can swap Box for Either to deal with that, but, it's also a bit moot really

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants