Skip to content

Commit

Permalink
Set timeout and and connection limit (argoproj#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
anhdat authored and VaibhavPage committed May 15, 2019
1 parent 8d91ab8 commit e43c316
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions gateways/transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1"
"net"
"net/http"
"time"

"github.com/argoproj/argo-events/pkg/apis/gateway/v1alpha1"

"github.com/argoproj/argo-events/common"
apicommon "github.com/argoproj/argo-events/pkg/apis/common"
pc "github.com/argoproj/argo-events/pkg/apis/common"
Expand Down Expand Up @@ -149,7 +151,17 @@ func (gc *GatewayConfig) postCloudEventToWatcher(host string, port string, endpo
return err
}
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}

client := &http.Client{
Timeout: 20 * time.Second,
Transport: &http.Transport{
Dial: (&net.Dialer{
KeepAlive: 600 * time.Second,
}).Dial,
MaxIdleConns: 100,
MaxIdleConnsPerHost: 50,
},
}
_, err = client.Do(req)
return err
}

0 comments on commit e43c316

Please sign in to comment.