Skip to content

Commit e55722e

Browse files
Fix: DefaultClient for monitor
1 parent 574345e commit e55722e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

node/monitor.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const (
2222

2323
// Monitor -
2424
type Monitor struct {
25-
url string
25+
url string
26+
client *http.Client
2627

2728
applied chan []*Applied
2829
refused chan []*FailedMonitor
@@ -39,12 +40,21 @@ type Monitor struct {
3940

4041
// NewMonitor -
4142
func NewMonitor(url string) *Monitor {
43+
t := http.DefaultTransport.(*http.Transport).Clone()
44+
t.MaxIdleConns = 100
45+
t.MaxConnsPerHost = 100
46+
t.MaxIdleConnsPerHost = 100
47+
4248
return &Monitor{
4349
url: strings.TrimSuffix(url, "/"),
4450
applied: make(chan []*Applied, 4096),
4551
refused: make(chan []*FailedMonitor, 4096),
4652
branchDelayed: make(chan []*FailedMonitor, 4096),
4753
branchRefused: make(chan []*FailedMonitor, 4096),
54+
client: &http.Client{
55+
Transport: t,
56+
Timeout: time.Minute,
57+
},
4858
}
4959
}
5060

@@ -211,11 +221,8 @@ func (monitor *Monitor) longPollingFailed(ctx context.Context, url string, ch ch
211221
if err != nil {
212222
return err
213223
}
214-
client := http.Client{
215-
Timeout: time.Minute,
216-
}
217224

218-
resp, err := client.Do(req)
225+
resp, err := monitor.client.Do(req)
219226
if err != nil {
220227
return err
221228
}

0 commit comments

Comments
 (0)