Open ynnadkrap opened 9 years ago
That's odd. All Send does is add the message to an internal channel. When you use NewClientWithFiles it also launches a goroutine with a RunLoop waiting to pull messages off that channel. I'm not sure what's happening here yet.
We're doing a blocking send on the notifs
channel, so if the notifs
channel becomes full, we'll block until a notification is dequeued.
The alternative is to use the select
syntax of posting to the channel, and reporting dropped messages. Something like this.
select {
case c.notifs <- n:
return nil;
default:
// Send would block, drop the notification.
return ErrNotificationDropped
}
or this:
select {
case c.notifs <- n:
default:
// Send would block, drop the notification.
if c.DropHandler != nil {
c.DropHandler(n)
}
}
Only read this comment if you're in the mood for crazy talk that isn't roadmapped and may never materialize:
Idea: the "drop" case could be used as a signal to open additional connections to the APNS gateway as needed for dealing with heavy load.
Yes, I'm just not sure why notifs would be blocking if there is only one notification being sent as in the example. @ynnadkrap Is there more to that example than you are showing?
c.Send(m) isn't returning and I'm not sure why. I created a client without error and am not receiving any errors on sent PNs.