From 43cd0c4308ceefa07bb18931b715efd0a98e8f2d Mon Sep 17 00:00:00 2001 From: Greg Pomerantz Date: Thu, 21 Nov 2024 09:43:01 -0500 Subject: [PATCH] Slow down polling. Throttle on "internal server error". --- go.mod | 2 +- go.sum | 2 ++ main.go | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 91af606..f5e1a47 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module git.wow.st/gmp/goget go 1.23.0 -require git.wow.st/gmp/ohlc v0.0.0-20241115023606-83f41a06596c // indirect +require git.wow.st/gmp/ohlc v0.0.0-20241115230120-714064615eb3 // indirect diff --git a/go.sum b/go.sum index 6493515..931e33a 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ git.wow.st/gmp/ohlc v0.0.0-20241115023606-83f41a06596c h1:etBdVfh2E4k00IzRBMuHsGm5HZg7S96JBZQpCGWshNE= git.wow.st/gmp/ohlc v0.0.0-20241115023606-83f41a06596c/go.mod h1:QSSqMCu9AFoYtfqA9Hbfpxy3mp5MT/d4fk0AzYnuoo8= +git.wow.st/gmp/ohlc v0.0.0-20241115230120-714064615eb3 h1:HDrgOSn1k2EzP0XIZbToUvwW3GXmZSnddq+/Zv2R4Mc= +git.wow.st/gmp/ohlc v0.0.0-20241115230120-714064615eb3/go.mod h1:QSSqMCu9AFoYtfqA9Hbfpxy3mp5MT/d4fk0AzYnuoo8= diff --git a/main.go b/main.go index e7839b0..6ae692a 100644 --- a/main.go +++ b/main.go @@ -12,12 +12,12 @@ import ( var ( retries = 5 - concurrency = 30 + concurrency = 1 ch chan string clk chan bool wg sync.WaitGroup - freq = time.Second / 30 + freq = time.Second * 15 throttle bool errs map[string]int mu sync.Mutex @@ -37,7 +37,7 @@ func get_(symbol string) (error) { return err } switch resp.StatusCode { - case 401, 429: + case 401, 429, 500: throttle = true return fmt.Errorf("%s", resp.Status) err_(symbol,0) // do not limit retries