mirror of
https://github.com/macports/mpbot-github.git
synced 2026-07-13 03:18:39 -07:00
Retry fetching Travis CI logs
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
|
||||
"github.com/hashicorp/go-retryablehttp"
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
)
|
||||
|
||||
var pasteURL = &url.URL{
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/macports/mpbot-github/pr/db"
|
||||
"github.com/macports/mpbot-github/pr/githubapi"
|
||||
)
|
||||
@@ -27,6 +28,7 @@ type Receiver struct {
|
||||
hookSecret []byte
|
||||
production bool
|
||||
testing bool
|
||||
httpClient *retryablehttp.Client
|
||||
githubClient githubapi.Client
|
||||
dbHelper db.DBHelper
|
||||
wg sync.WaitGroup
|
||||
@@ -41,6 +43,7 @@ func NewReceiver(listenAddr string, hookSecret []byte, botSecret string, product
|
||||
server: &http.Server{Addr: listenAddr},
|
||||
hookSecret: hookSecret,
|
||||
production: production,
|
||||
httpClient: retryablehttp.NewClient(),
|
||||
githubClient: githubapi.NewClient(botSecret),
|
||||
dbHelper: dbHelper,
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
retryablehttp "github.com/hashicorp/go-retryablehttp"
|
||||
"github.com/macports/mpbot-github/ci/logger/constants"
|
||||
)
|
||||
|
||||
@@ -77,7 +77,7 @@ func (receiver *Receiver) handleTravisWebhook(payload TravisWebhookPayload) {
|
||||
log.Println("Processing " + strconv.Itoa(len(payload.Matrix)) + " job(s)")
|
||||
|
||||
for _, job := range payload.Matrix {
|
||||
req, err := http.NewRequest(
|
||||
req, err := retryablehttp.NewRequest(
|
||||
"GET",
|
||||
"https://api.travis-ci.org/job/"+strconv.Itoa(job.ID)+"/log",
|
||||
nil,
|
||||
@@ -91,7 +91,7 @@ func (receiver *Receiver) handleTravisWebhook(payload TravisWebhookPayload) {
|
||||
|
||||
log.Println("Fetching logs for job #" + strconv.Itoa(job.ID))
|
||||
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
resp, err := receiver.httpClient.Do(req)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user