Commit 63efef57 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Make retryable http client more verbose if verbose flag is on

parent 018e45d6
...@@ -7,8 +7,10 @@ import ( ...@@ -7,8 +7,10 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"net" "net"
"net/http" "net/http"
"os"
"path/filepath" "path/filepath"
"strings" "strings"
"time" "time"
...@@ -29,6 +31,14 @@ type HTTPTransport struct { ...@@ -29,6 +31,14 @@ type HTTPTransport struct {
const verbose = false const verbose = false
var transportlogger *log.Logger
func init() {
if verbose {
transportlogger = log.New(os.Stdout, "transport: ", 0)
}
}
// NewHTTPTransport returns a new HTTPTransport. // NewHTTPTransport returns a new HTTPTransport.
func NewHTTPTransport(serverURL string) *HTTPTransport { func NewHTTPTransport(serverURL string) *HTTPTransport {
url := serverURL url := serverURL
...@@ -54,7 +64,7 @@ func NewHTTPTransport(serverURL string) *HTTPTransport { ...@@ -54,7 +64,7 @@ func NewHTTPTransport(serverURL string) *HTTPTransport {
client.RetryMax = 3 client.RetryMax = 3
client.RetryWaitMin = 100 * time.Millisecond client.RetryWaitMin = 100 * time.Millisecond
client.RetryWaitMax = 500 * time.Millisecond client.RetryWaitMax = 500 * time.Millisecond
client.Logger = nil client.Logger = transportlogger
client.HTTPClient = &http.Client{ client.HTTPClient = &http.Client{
Timeout: time.Second * 5, Timeout: time.Second * 5,
Transport: &innerTransport, Transport: &innerTransport,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment