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 ability to handle events that expect an ack #463

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mendess
Copy link

@mendess mendess commented Sep 16, 2024

This adds three new methods to the API surface

  • [Raw]Client::ack(AckId, D)
  • ClientBuilder::on_with_ack(Event, callback)
  • ClientBuilder::on_any_with_ack(Event, callback)

using these it's possible to receive messages that require ack and acknowledge them

Fixes #461

@mendess
Copy link
Author

mendess commented Sep 16, 2024

I didn't add any tests because I didn't have the time to do it yet. But I've tested locally with my usecase and it seems to work

Copy link
Collaborator

@ctrlaltf24 ctrlaltf24 left a comment

Choose a reason for hiding this comment

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

suggestion: rename added internal functions to ..._with_awk (rather than having _no_awk variants)

suggestion: add tests so the feature continues to be tested and working

after that it looks good

socketio/src/client/builder.rs Outdated Show resolved Hide resolved
@@ -25,7 +25,7 @@ pub struct Packet {
pub packet_type: PacketId,
pub nsp: String,
pub data: Option<String>,
pub id: Option<i32>,
pub id: Option<AckId>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While I'm generally a fan of wrapper types, it's not worth the breaking API change.

Copy link
Author

Choose a reason for hiding this comment

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

the reason I put this in is just so you can't make a mistake when calling ack on the client. Since you're not supposed to care what the ack id is I think this is a good change and it's better to make this change sooner rather than later. If you still disagree I can drop it

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree it's a reasonable change, but it would need to be made (and merged) separately.

Copy link
Owner

Choose a reason for hiding this comment

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

I also agree that this is a reasonable change, but please factor It out in separate commit / PR. This breaks existing users that depend on an i32 in this place and we cannot just ignore that. That being said, thanks for spotting this appropriately :)

@mendess
Copy link
Author

mendess commented Oct 16, 2024

suggestion: add tests so the feature continues to be tested and working

I could not figure out how to run the test-all recipe of the makefile, hence I didn't write any tests. I think docs could be improved on this in a later PR. For now can you tell me how I can run the tests?

@mendess mendess force-pushed the mendess/ack-server-request branch from b5935fb to 034578f Compare October 16, 2024 19:25
@ctrlaltf24
Copy link
Collaborator

suggestion: add tests so the feature continues to be tested and working

I could not figure out how to run the test-all recipe of the makefile, hence I didn't write any tests. I think docs could be improved on this in a later PR. For now can you tell me how I can run the tests?

agreed, that target is a little lacking. You need to start up the test containers beforehand as seen in the ci: https://github.com/1c3t3a/rust-socketio/blob/2ef32ecbe053d100e350c4d77a71dd1cab19471e/.github/workflows/test.yml#L36C11-L37C133, speaking of which I'll turn that on for you (it'll run on every push if you can't get it running locally)

@mendess mendess force-pushed the mendess/ack-server-request branch from 034578f to a290bc2 Compare October 16, 2024 21:27
@mendess mendess force-pushed the mendess/ack-server-request branch from a290bc2 to e69af99 Compare November 24, 2024 13:51
Copy link
Owner

@1c3t3a 1c3t3a left a comment

Choose a reason for hiding this comment

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

First of all, sorry for the late response.

Thanks a lot for working on this, it generally LGTM!

Regarding the tests: It'd be great to have them and I improved the make test-all target in #477.

Would be amazing if you could add the tests and split the AckId change out, then we're ready to merge this!

@mendess mendess closed this Nov 24, 2024
@mendess mendess force-pushed the mendess/ack-server-request branch from e69af99 to a4e5287 Compare November 24, 2024 14:32
@mendess mendess reopened this Nov 24, 2024
@mendess
Copy link
Author

mendess commented Nov 24, 2024

Wtf github? I didn't close this 🤔 maybe it got confused when I was syncing my fork

@mendess mendess force-pushed the mendess/ack-server-request branch from 55d1a0f to 8526e48 Compare November 24, 2024 14:58
@mendess
Copy link
Author

mendess commented Nov 24, 2024

I have removed the ack id commit and will make a separate PR for it later. I've run the test-all tests locally and it all passes. I also made a small modification to the makefile so that I could run the tests multiple times

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.

Receiving a message from the server that requires an ack
3 participants