From 21f6fe3a3d11a11ecfa8575370da6e5e197efb3f Mon Sep 17 00:00:00 2001 From: Kat Joyce Date: Tue, 12 Apr 2016 16:47:22 +0100 Subject: [PATCH] Separate url client from log client (#1150) --- fixchain/fix_and_log.go | 4 ++-- fixchain/fix_and_log_test.go | 3 ++- fixchain/main/fixchain.go | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fixchain/fix_and_log.go b/fixchain/fix_and_log.go index f8f78068d8..0431f67f06 100644 --- a/fixchain/fix_and_log.go +++ b/fixchain/fix_and_log.go @@ -74,12 +74,12 @@ func (fl *FixAndLog) Wait() { // are added to its queue, and then log them to the Certificate Transparency log // found at the given url. Any errors encountered along the way are pushed to // the given errors channel. -func NewFixAndLog(fixerWorkerCount int, loggerWorkerCount int, errors chan<- *FixError, client *http.Client, logURL string, limiter Limiter, logStats bool) *FixAndLog { +func NewFixAndLog(fixerWorkerCount int, loggerWorkerCount int, errors chan<- *FixError, client *http.Client, logClient *http.Client, logURL string, limiter Limiter, logStats bool) *FixAndLog { chains := make(chan []*x509.Certificate) fl := &FixAndLog{ fixer: NewFixer(fixerWorkerCount, chains, errors, client, logStats), chains: chains, - logger: NewLogger(loggerWorkerCount, logURL, errors, client, limiter, logStats), + logger: NewLogger(loggerWorkerCount, logURL, errors, logClient, limiter, logStats), done: newLockedMap(), } diff --git a/fixchain/fix_and_log_test.go b/fixchain/fix_and_log_test.go index 768217ee7e..618aea328a 100644 --- a/fixchain/fix_and_log_test.go +++ b/fixchain/fix_and_log_test.go @@ -184,7 +184,8 @@ func TestNewFixAndLog(t *testing.T) { for i, test := range newFixAndLogTests { seen := make([]bool, len(test.expLoggedChains)) errors := make(chan *FixError) - fl := NewFixAndLog(1, 1, errors, &http.Client{Transport: &testRoundTripper{t: t, test: &test, testIndex: i, seen: seen}}, test.url, newNilLimiter(), false) + client := &http.Client{Transport: &testRoundTripper{t: t, test: &test, testIndex: i, seen: seen}} + fl := NewFixAndLog(1, 1, errors, client, client, test.url, newNilLimiter(), false) var wg sync.WaitGroup wg.Add(1) diff --git a/fixchain/main/fixchain.go b/fixchain/main/fixchain.go index 3d662b409e..210396e640 100644 --- a/fixchain/main/fixchain.go +++ b/fixchain/main/fixchain.go @@ -103,7 +103,8 @@ func main() { go logStringErrors(&wg, errors, errDir) limiter := ratelimiter.NewLimiter(1000) - fl := fixchain.NewFixAndLog(100, 100, errors, &http.Client{}, logURL, limiter, true) + client := &http.Client{} + fl := fixchain.NewFixAndLog(100, 100, errors, client, client, logURL, limiter, true) processChains(chainsFile, fl)