- Removed passive load balancer and default to active lb only
This commit is contained in:
Toby Chui 2025-02-20 20:25:20 +08:00
parent 394cf50e1d
commit 20959cd6cc
2 changed files with 2 additions and 5 deletions

View File

@ -3,7 +3,6 @@ package loadbalance
import ( import (
"strconv" "strconv"
"strings" "strings"
"time"
) )
// Return if the target host is online // Return if the target host is online
@ -36,6 +35,7 @@ func (m *RouteManager) NotifyHostOnlineState(upstreamIP string, isOnline bool) {
// Set this host unreachable for a given amount of time defined in timeout // Set this host unreachable for a given amount of time defined in timeout
// this shall be used in passive fallback. The uptime monitor should call to NotifyHostOnlineState() instead // this shall be used in passive fallback. The uptime monitor should call to NotifyHostOnlineState() instead
/*
func (m *RouteManager) NotifyHostUnreachableWithTimeout(upstreamIp string, timeout int64) { func (m *RouteManager) NotifyHostUnreachableWithTimeout(upstreamIp string, timeout int64) {
//if the upstream IP contains http or https, strip it //if the upstream IP contains http or https, strip it
upstreamIp = strings.TrimPrefix(upstreamIp, "http://") upstreamIp = strings.TrimPrefix(upstreamIp, "http://")
@ -58,6 +58,7 @@ func (m *RouteManager) NotifyHostUnreachableWithTimeout(upstreamIp string, timeo
m.NotifyHostOnlineState(upstreamIp, true) m.NotifyHostOnlineState(upstreamIp, true)
}() }()
} }
*/
// FilterOfflineOrigins return only online origins from a list of origins // FilterOfflineOrigins return only online origins from a list of origins
func (m *RouteManager) FilterOfflineOrigins(origins []*Upstream) []*Upstream { func (m *RouteManager) FilterOfflineOrigins(origins []*Upstream) []*Upstream {

View File

@ -3,7 +3,6 @@ package dynamicproxy
import ( import (
"context" "context"
"errors" "errors"
"fmt"
"log" "log"
"net" "net"
"net/http" "net/http"
@ -211,9 +210,6 @@ func (h *ProxyHandler) hostRequest(w http.ResponseWriter, r *http.Request, targe
http.Error(w, "Request canceled", http.StatusRequestTimeout) http.Error(w, "Request canceled", http.StatusRequestTimeout)
h.Parent.logRequest(r, false, http.StatusRequestTimeout, "host-http", r.URL.Hostname()) h.Parent.logRequest(r, false, http.StatusRequestTimeout, "host-http", r.URL.Hostname())
} else { } else {
//Notify the load balancer that the host is unreachable
fmt.Println(err.Error())
h.Parent.loadBalancer.NotifyHostUnreachableWithTimeout(selectedUpstream.OriginIpOrDomain, PassiveLoadBalanceNotifyTimeout)
http.ServeFile(w, r, "./web/rperror.html") http.ServeFile(w, r, "./web/rperror.html")
h.Parent.logRequest(r, false, 521, "host-http", r.URL.Hostname()) h.Parent.logRequest(r, false, 521, "host-http", r.URL.Hostname())
} }