mirror of https://github.com/tidwall/tile38.git
Merge branch 'master' of https://github.com/tidwall/tile38
This commit is contained in:
commit
a5b8621557
|
@ -6,7 +6,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,7 +16,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type HTTPEndpointConn struct {
|
type HTTPEndpointConn struct {
|
||||||
mu sync.Mutex
|
|
||||||
ep Endpoint
|
ep Endpoint
|
||||||
client *http.Client
|
client *http.Client
|
||||||
}
|
}
|
||||||
|
@ -25,6 +23,13 @@ type HTTPEndpointConn struct {
|
||||||
func newHTTPEndpointConn(ep Endpoint) *HTTPEndpointConn {
|
func newHTTPEndpointConn(ep Endpoint) *HTTPEndpointConn {
|
||||||
return &HTTPEndpointConn{
|
return &HTTPEndpointConn{
|
||||||
ep: ep,
|
ep: ep,
|
||||||
|
client: &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
MaxIdleConnsPerHost: httpMaxIdleConnections,
|
||||||
|
IdleConnTimeout: httpExpiresAfter,
|
||||||
|
},
|
||||||
|
Timeout: httpRequestTimeout,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,18 +38,6 @@ func (conn *HTTPEndpointConn) Expired() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *HTTPEndpointConn) Send(msg string) error {
|
func (conn *HTTPEndpointConn) Send(msg string) error {
|
||||||
conn.mu.Lock()
|
|
||||||
defer conn.mu.Unlock()
|
|
||||||
|
|
||||||
if conn.client == nil {
|
|
||||||
conn.client = &http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
MaxIdleConnsPerHost: httpMaxIdleConnections,
|
|
||||||
IdleConnTimeout: httpExpiresAfter,
|
|
||||||
},
|
|
||||||
Timeout: httpRequestTimeout,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
req, err := http.NewRequest("POST", conn.ep.Original, bytes.NewBufferString(msg))
|
req, err := http.NewRequest("POST", conn.ep.Original, bytes.NewBufferString(msg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue