forked from smancke/guble
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/pn 310 sms ttl #15
Open
bogh
wants to merge
25
commits into
master
Choose a base branch
from
feature/pn-310-sms-ttl
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 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
1aec698
SMS check expired messages
bogh 2445c37
Merge branch 'master' into feature/pn-310-sms-ttl
fd82c39
Merge branch 'master' into feature/pn-310-sms-ttl
bogh 7845188
Simplify method according to PR
bogh 3df9fea
Merge branch 'feature/pn-310-sms-ttl' of https://github.com/cosminren…
bogh fc351ad
Merge branch 'master' into feature/pn-310-sms-ttl
bogh 613c7da
fix typo; add assert for metrics value
ab14544
added a Prometheus metric for expired messages; moved test
729b498
Change message `Expires` field to be a timestamp
bogh d0d4124
Merge branch 'master' into feature/pn-310-ttl-change-to-timestamp
d8428d3
Merge branch 'master' into feature/pn-310-ttl-change-to-timestamp
bfc87cf
Merge branch 'master' into feature/pn-310-sms-ttl
f4b2626
Merge branch 'master' of https://github.com/cosminrentea/gobbler into…
bogh 8770557
Merge branch 'master' into feature/pn-310-sms-ttl
bogh 73bdeee
Allow for empty expires field
bogh 14342e4
Fix errors
bogh 5344e5e
PR requested changes
bogh 3994ae3
Read `Expires` message field from header for guble message
bogh ae6ac02
Set Expires field in rest client
bogh 2ba024c
Merge branch 'feature/pn-310-sms-ttl' into feature/pn-310-ttl-for-mes…
bogh 36d8439
Merge branch 'feature/pn-310-ttl-rest' into feature/pn-310-ttl-for-me…
bogh 88d3cae
Merge branch 'feature/pn-310-sms-ttl' of https://github.com/cosminren…
bogh 163654c
Merge branch 'feature/pn-310-sms-ttl' into feature/pn-310-ttl-for-mes…
bogh 9f6dec6
Return error when message is expired
bogh da2ee2d
Merge branch 'feature/pn-310-ttl-for-messages' into feature/pn-310-sm…
bogh 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
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 |
---|---|---|
|
@@ -138,6 +138,17 @@ func (ns *NexmoSender) Send(msg *protocol.Message) error { | |
return ErrRetryFailed | ||
} | ||
|
||
if msg.IsExpired() { | ||
log.WithFields(log.Fields{ | ||
"ID": msg.ID, | ||
"To": nexmoSMS.To, | ||
"Expires": msg.Expires.Format(time.RFC3339), | ||
"Created": time.Unix(msg.Time, 0).Format(time.RFC3339), | ||
}).Info("Expired message received") | ||
mTotalExpiredMessages.Add(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a prometheus equivalent for this in another PR |
||
return nil | ||
} | ||
|
||
sendSms := func() (*NexmoMessageResponse, error) { | ||
return ns.sendSms(nexmoSMS) | ||
} | ||
|
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,6 +1,7 @@ | ||
package sms | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
"time" | ||
|
||
|
@@ -35,3 +36,26 @@ func TestNexmoSender_SendWithError(t *testing.T) { | |
a.Error(err) | ||
a.Equal(ErrRetryFailed, err) | ||
} | ||
|
||
func TestNexmoSender_SendExpiredMessage(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: I moved the test to sms_integration_test.go |
||
a := assert.New(t) | ||
|
||
port := createRandomPort(7000, 8000) | ||
URL = "http://127.0.0.1" + port | ||
|
||
sender := createNexmoSender(t) | ||
// no request should be made in case the sms is expired | ||
go dummyNexmoEndpointWithHandlerFunc(t, nil, port, func(t *testing.T, countCh chan bool) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
a.FailNow("Nexmo call not expected.") | ||
} | ||
}) | ||
|
||
msg := encodeProtocolMessage(t, 0) | ||
expires := time.Now().Add(-1 * time.Hour) | ||
msg.Expires = &expires | ||
|
||
err := sender.Send(&msg) | ||
time.Sleep(3 * timeInterval) | ||
a.NoError(err) | ||
} |
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
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.
👍