-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from nyaruka/sending
Add sending support to courier, plug in sentry, log request and respo…
- Loading branch information
Showing
100 changed files
with
11,491 additions
and
582 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package rapidpro | ||
|
||
import ( | ||
"fmt" | ||
|
||
"time" | ||
|
||
"github.com/nyaruka/courier" | ||
) | ||
|
||
const insertLogSQL = ` | ||
INSERT INTO channels_channellog("channel_id", "msg_id", "description", "is_error", "url", "request", "response", "response_status", "created_on", "request_time") | ||
VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) | ||
` | ||
|
||
// WriteChannelLog writes the passed in channel log to the database, we do not queue on errors but instead just throw away the log | ||
func writeChannelLog(b *backend, log *courier.ChannelLog) error { | ||
// cast our channel to our own channel type | ||
dbChan, isChan := log.Channel.(*DBChannel) | ||
if !isChan { | ||
return fmt.Errorf("unable to write non-rapidpro channel logs") | ||
} | ||
|
||
description := "Success" | ||
if log.Error != "" { | ||
description = fmt.Sprintf("Error: %s", log.Error) | ||
} | ||
|
||
_, err := b.db.Exec(insertLogSQL, dbChan.ID(), log.MsgID, description, log.Error != "", log.URL, | ||
log.Request, log.Response, log.StatusCode, log.CreatedOn, log.Elapsed/time.Millisecond) | ||
|
||
return 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
Oops, something went wrong.