Skip to content

Commit

Permalink
Fix parallel ingest when guacgql is in docker. (#900)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Mendoza <jlm@jlm.name>
  • Loading branch information
jeffmendoza committed May 31, 2023
1 parent e9063d4 commit 08bbd69
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cmd/guacone/cmd/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"errors"
"fmt"
"net"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -227,7 +228,24 @@ func getIngestor(ctx context.Context) func(processor.DocumentTree) ([]assembler.
}

func getAssembler(ctx context.Context, graphqlEndpoint string) func([]assembler.IngestPredicates) error {
httpClient := http.Client{}
// Same as https://pkg.go.dev/net/http#DefaultTransport but with greater
// MaxIdleConnsPerHost so that we effectively re-use connections when doing
// parallel ingestion calls.
var dialer = &net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
var customTransport http.RoundTripper = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialer.DialContext,
ForceAttemptHTTP2: true,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 30,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}
httpClient := http.Client{Transport: customTransport}
gqlclient := graphql.NewClient(graphqlEndpoint, &httpClient)
f := helpers.GetParallelAssembler(ctx, gqlclient)
return f
Expand Down

0 comments on commit 08bbd69

Please sign in to comment.