added round_robin, least_conn and ip_hash load balance support, small refactoring

This commit is contained in:
yusing
2024-10-09 10:39:07 +08:00
parent 1797896fa6
commit 5c40f4aa84
24 changed files with 739 additions and 64 deletions

View File

@@ -2,7 +2,6 @@ package idlewatcher
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"strconv"
@@ -19,10 +18,6 @@ type Waker struct {
}
func NewWaker(w *watcher, rp *gphttp.ReverseProxy) *Waker {
tr := &http.Transport{}
if w.NoTLSVerify {
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}
orig := rp.ServeHTTP
// workaround for stopped containers port become zero
rp.ServeHTTP = func(rw http.ResponseWriter, r *http.Request) {
@@ -41,7 +36,7 @@ func NewWaker(w *watcher, rp *gphttp.ReverseProxy) *Waker {
watcher: w,
client: &http.Client{
Timeout: 1 * time.Second,
Transport: tr,
Transport: rp.Transport,
},
rp: rp,
}