aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2020-10-30 17:07:06 +0000
committerr <r@freesoftwareextremist.com>2020-10-30 17:07:06 +0000
commit140dfe2f638e755fa137995a29f2f44aa0b8c310 (patch)
tree1fe05a7c767451dee658521a9d4ac5329025f4ab /main.go
parent237182c171beafc2d823fa6ea319bdd7e7209190 (diff)
downloadbloat-140dfe2f638e755fa137995a29f2f44aa0b8c310.tar.gz
bloat-140dfe2f638e755fa137995a29f2f44aa0b8c310.zip
Fix http client
- Remove automatic retries on 429 - Tweak http client config for better connection re-using
Diffstat (limited to 'main.go')
-rw-r--r--main.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/main.go b/main.go
index 87be0d2..80baa81 100644
--- a/main.go
+++ b/main.go
@@ -4,10 +4,12 @@ import (
"errors"
"fmt"
"log"
+ "net"
"net/http"
"os"
"path/filepath"
"strings"
+ "time"
"bloat/config"
"bloat/kv"
@@ -26,6 +28,20 @@ func errExit(err error) {
os.Exit(1)
}
+func setupHttp() {
+ tr := http.DefaultTransport.(*http.Transport)
+ tr.MaxIdleConnsPerHost = 30
+ tr.MaxIdleConns = 300
+ tr.ForceAttemptHTTP2 = false
+ tr.DialContext = (&net.Dialer{
+ Timeout: 30 * time.Second,
+ KeepAlive: 3 * time.Minute,
+ DualStack: true,
+ }).DialContext
+ client := http.DefaultClient
+ client.Transport = tr
+}
+
func main() {
opts, _, err := util.Getopts(os.Args, "f:")
if err != nil {
@@ -93,6 +109,8 @@ func main() {
logger = log.New(lf, "", log.LstdFlags)
}
+ setupHttp()
+
s := service.NewService(config.ClientName, config.ClientScope,
config.ClientWebsite, customCSS, config.PostFormats, renderer,
sessionRepo, appRepo, config.SingleInstance)