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

wormhole: Collect messages without using reflect package #95

Closed
wants to merge 2 commits into from

Conversation

Jacalz
Copy link
Contributor

@Jacalz Jacalz commented Apr 17, 2023

This implements the message collection in the waitFor method without using the reflect package. We can use a type switch and copy over the field values directly and also make sure that non-pointer values or unsupported collector types return an error.

This implementation uses a bit less "magic" and is more understandable in my opinion.

Supersedes #94

@Jacalz
Copy link
Contributor Author

Jacalz commented Apr 17, 2023

Test failure does not seem to be a fault of this PR. Tests are passing locally for me.

@Jacalz
Copy link
Contributor Author

Jacalz commented Apr 18, 2023

I rewrote the code to only use one type cast and make everything more readable over all.

@psanford
Copy link
Owner

Refect isn't magic. Its a fairly normal pattern in the stdlib (e.g. encoding/json encoding/xml). I don't consider the additional code to be better.

@psanford psanford closed this Aug 17, 2023
@Jacalz
Copy link
Contributor Author

Jacalz commented Aug 17, 2023

Yes it isn't magic but it also should be used very sparingly. I agree to disagree.

@Jacalz Jacalz deleted the waitForNoReflect branch August 17, 2023 06:29
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.

None yet

2 participants