-
Notifications
You must be signed in to change notification settings - Fork 47
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
Develop client/session separation #51
Open
nathany
wants to merge
34
commits into
master
Choose a base branch
from
develop
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
f985ea7
Start performing a lot more error checking in Send()
bdotdub 350d3e3
Pass the original notification through if we want it with Notificatio…
bdotdub 7ce2c47
Undo NotificationResult api change
bdotdub f162ced
WIP
bdotdub d308f5e
Start simplifying the client internals
bdotdub 64b0fc2
Update example
bdotdub 4a7edba
Add connection resource locking
bdotdub e883640
Update notification test and remove old client test file
bdotdub 0323581
WIP Convert Conn into an interface and make feedback test
bdotdub e2b7609
Lengthen timeouts for real tcp conn negotiation stuff
bdotdub abc584f
Add race detection
bdotdub 1a7760c
Extend timeout
bdotdub 2c85a0a
Start filling out client test
bdotdub 9e1b5bb
Remove extraneous function
bdotdub 4fa74c9
Adding more client tests
bdotdub df2b03d
Introduce session concept
bdotdub 06384bf
Fix example
bdotdub d807d6b
Add more tests for client
bdotdub 12a1dfa
Beginnings of a session test
bdotdub f87a8ee
Synchronize around the session state
bdotdub 1456b9b
How do you even logic
bdotdub f841b7e
Clean up session states
bdotdub b8a8e42
Revise Travis CI config
nathany 915e3b9
travis ci: notifications
nathany 227fbfd
Merge pull request #39 from timehop/travis
nathany 509f1d7
document exported identifiers
nathany 89c02e1
ErrUnrecognizedErrorResponse
nathany c58921f
Merge pull request #41 from timehop/docs
nathany 933c627
split out SetReadDeadline
nathany 54aab15
keep NotificationResult
nathany 3fa96ef
remove determineIdentifier (auto ID)
nathany 0b6d1b0
move sent buffer code
nathany 57489e7
find requeueable notifications on buffer
nathany 55cf34e
catch json marshal errors
nathany File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
sudo: false | ||
language: go | ||
go: | ||
- 1.3 | ||
services: | ||
- redis-server | ||
- 1.4.2 | ||
before_script: | ||
- go get github.com/onsi/ginkgo | ||
- go get github.com/onsi/gomega | ||
- go get code.google.com/p/go.tools/cmd/cover | ||
- go get golang.org/x/tools/cmd/cover | ||
- go install github.com/onsi/ginkgo/ginkgo | ||
script: ginkgo -r --skipMeasurements --cover --trace | ||
script: ginkgo -r --skipMeasurements --cover --trace --race | ||
env: | ||
global: | ||
- PATH=$HOME/gopath/bin:$PATH | ||
|
||
notifications: | ||
email: false | ||
|
||
branches: | ||
only: | ||
- master | ||
- develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package apns | ||
|
||
import ( | ||
"container/list" | ||
"sync" | ||
) | ||
|
||
// circular buffer of sent messages | ||
// to retry if connection is dropped | ||
type buffer struct { | ||
size int | ||
m sync.Mutex | ||
*list.List | ||
} | ||
|
||
func newBuffer(size int) *buffer { | ||
return &buffer{size, sync.Mutex{}, list.New()} | ||
} | ||
|
||
func (b *buffer) Add(v interface{}) *list.Element { | ||
b.m.Lock() | ||
defer b.m.Unlock() | ||
|
||
e := b.PushBack(v) | ||
|
||
if b.Len() > b.size { | ||
b.Remove(b.Front()) | ||
} | ||
|
||
return e | ||
} | ||
|
||
// NotificationResult associates an error from Apple to a notification. | ||
type NotificationResult struct { | ||
Notif Notification | ||
Err Error | ||
} | ||
|
||
func (s NotificationResult) Error() string { | ||
return s.Err.Error() | ||
} | ||
|
||
func (b *buffer) FindFailedNotification(e Error) NotificationResult { | ||
for cursor := b.Back(); cursor != nil; cursor = cursor.Prev() { | ||
// Get serialized notification | ||
n, _ := cursor.Value.(Notification) | ||
|
||
// If the notification, move cursor after the trouble notification | ||
if n.Identifier == e.Identifier { | ||
return NotificationResult{n, e} | ||
} | ||
} | ||
return NotificationResult{Notification{}, e} | ||
} | ||
|
||
// RequeueableNotifications returns good notifications sent after an error. | ||
func (b *buffer) RequeueableNotifications(identifier uint32) []Notification { | ||
notifs := []Notification{} | ||
|
||
// Walk back to last known good notification and return the slice | ||
var e *list.Element | ||
for e = b.Front(); e != nil; e = e.Next() { | ||
if n, ok := e.Value.(Notification); ok && n.Identifier == identifier { | ||
break | ||
} | ||
} | ||
|
||
// Start right after errored ID and get the rest of the list | ||
for e = e.Next(); e != nil; e = e.Next() { | ||
n, ok := e.Value.(Notification) | ||
if !ok { | ||
continue | ||
} | ||
|
||
notifs = append(notifs, n) | ||
} | ||
|
||
return notifs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package apns | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
// . "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Session", func() { | ||
Describe("RequeueableNotifications", func() { | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't being used yet.