From 53e2e21ee65dfd43fbecb343ac1cd3a8284d4576 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Thu, 16 Jun 2022 21:58:59 +0200 Subject: [PATCH] Use compression (#17) --- cmd/connect.go | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/connect.go b/cmd/connect.go index 5df4256..87f6a42 100644 --- a/cmd/connect.go +++ b/cmd/connect.go @@ -9,6 +9,7 @@ import ( "log" "net/http" "strings" + "time" "github.com/OpenSlides/openslides-performance/client" "github.com/spf13/cobra" @@ -55,10 +56,23 @@ func cmdConnect(cfg *config) *cobra.Command { for i := 0; i < *connectionCount; i++ { go func(i int) { - r, err := keepOpen(ctx, c, "/system/autoupdate", strings.NewReader(*autoupdateBody)) - if err != nil { - log.Printf("Can not send request %d: %v", i, err) - return + var r io.ReadCloser + for tries := 0; ; tries++ { + if tries > 100 { + return + } + + r, err = keepOpen(ctx, c, "/system/autoupdate?compress=1", strings.NewReader(*autoupdateBody)) + if err != nil { + if ctx.Err() != nil { + return + } + + log.Printf("Can not send request %d: %v", i, err) + time.Sleep(time.Second) + continue + } + break } defer r.Close()