Skip to content

Commit

Permalink
Use compression (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar committed Jun 16, 2022
1 parent ea61c10 commit 53e2e21
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"strings"
"time"

"github.com/OpenSlides/openslides-performance/client"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 53e2e21

Please sign in to comment.