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

Move notification struct error checking before queueing it in run loop #17

Closed
wants to merge 3 commits into from

Conversation

bdotdub
Copy link
Contributor

@bdotdub bdotdub commented Dec 12, 2014

This PR passes back validation and serialization errors synchronously to the caller of Send() instead of...well...ignoring it in the run loop or having to read off of another channel.

Fixes #4

@bdotdub bdotdub assigned biasedbit and unassigned biasedbit Dec 12, 2014
@bdotdub
Copy link
Contributor Author

bdotdub commented Dec 12, 2014

@tylrtrmbl @nathany @brunodecarvalho if anyone has some spare 👀, this should help a bit with #4

@nathany
Copy link
Contributor

nathany commented Dec 12, 2014

@bdotdub If it's okay, I might not get to this until next Wednesday.

@taylortrimble
Copy link
Contributor

Actually, I changed my mind back again from #4. I think it makes sense to use the synchronization and information passing mechanism you have now (a channel of Notification structs) and simply use FailedNotifs to report both user (ToBinary) and Apple (conn.Send) errors.

From my perspective, there's no reason I would need to know if the error came from conn.Send or somewhere else.

@taylortrimble
Copy link
Contributor

What's up with Travis CI by the way?

@nathany
Copy link
Contributor

nathany commented Dec 15, 2014

Personally I'd prefer Send return errors when it can.

But then I'm trying to build a synchronous API around Send and FailedNotifs that gives me back Apple's response or a timeout.

@bdotdub
Copy link
Contributor Author

bdotdub commented Dec 15, 2014

I've been thinking a lot about this and am feeling like we should have Send() return all of the errors and forego FailedNotifs. If the client is disconnected from Apple, sending a notification shouldn't disappear into the run loop and eventually pop out of the other end through FailedNotifs.

The API feels cleaner to me if I get an error when trying to call Send() while we're disconnected. This will make it clear when we have connection issues with Apple and the caller code can check whether the error is ErrGatewayDisconnected or something and which would make the caller is responsible for calling Connect() in that case.

@taylortrimble
Copy link
Contributor

You're suggesting a synchronous API then?

@bdotdub
Copy link
Contributor Author

bdotdub commented Dec 15, 2014

Yeah - it'll require a lot less bookkeeping internally and will push that option to the caller.

@bdotdub
Copy link
Contributor Author

bdotdub commented Dec 15, 2014

Especially since the actually sending is basically synchronous on one tcp connection

@biasedbit
Copy link
Contributor

👍 for the synchronous API/pushing that responsibility to the caller.

@taylortrimble
Copy link
Contributor

👍 For me too, actually. I actually prefer that the caller have granular control over stuff like that. Consider my previous comments as "assuming you wanted to keep it async".

Excited to see it now!

@bdotdub
Copy link
Contributor Author

bdotdub commented Dec 16, 2014

Going to hold off on merging this for now. I've got some code in the hopper that'll fixes up the internals to be less confusing as mentioned here.

@nathany
Copy link
Contributor

nathany commented Dec 17, 2014

This sounds pretty great and will really help make the API solid. But now I'm waiting for this to magically solve #16 instead of coming up with a solution.

@nathany
Copy link
Contributor

nathany commented Dec 17, 2014

Hoping #14 and #9 can get merged before going too far down this path.

@nathany
Copy link
Contributor

nathany commented Jan 14, 2015

@bdotdub Pushing some error handling back to user of the library sounds good. Say, if a certificate has expired, it shouldn't continue retrying (I've yet to confirm what the current behaviour is).

@bdotdub
Copy link
Contributor Author

bdotdub commented Mar 2, 2015

Closing this in favor of #31 and #33

@bdotdub bdotdub closed this Mar 2, 2015
@bdotdub bdotdub deleted the bw-refactor-notification-sending branch March 2, 2015 16:04
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.

Report Error for Malformed Device Token
4 participants