Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/appleboy/loadbalancer-algorithms
/ functions
Functions
64 in github.com/appleboy/loadbalancer-algorithms
⨍
Functions
64
◇
Types & classes
10
↓ 40 callers
Function
NewProxy
NewProxy creates a new instance of Proxy with the specified address.
proxy/proxy.go:20
↓ 38 callers
Method
NextServer
()
weighted/weighted.go:20
↓ 19 callers
Method
GetName
GetName returns the name of the proxy.
proxy/proxy.go:55
↓ 12 callers
Function
New
New creates a new instance of the round-robin load balancer with the specified servers. If no servers are provided, it creates an empty load balancer
roundrobin/roundrobin.go:151
↓ 7 callers
Method
Servers
()
weighted/weighted.go:23
↓ 4 callers
Method
AddServer
(*url.URL, int)
weighted/weighted.go:21
↓ 4 callers
Method
AddServers
AddServers adds one or more servers to the load balancer.
roundrobin/roundrobin.go:20
↓ 4 callers
Function
New
()
weighted/weighted.go:151
↓ 3 callers
Method
RemoveAll
()
weighted/weighted.go:24
↓ 2 callers
Method
IsAvailable
IsAvailable returns whether the proxy origin was successfully connected at the last check time.
proxy/health/health.go:132
↓ 2 callers
Function
New
(origin *url.URL, opts ...Opts)
proxy/health/health.go:27
↓ 2 callers
Method
RemoveServer
(*url.URL)
weighted/weighted.go:22
↓ 2 callers
Method
RemoveServers
RemoveServers removes one or more servers from the load balancer.
roundrobin/roundrobin.go:23
↓ 2 callers
Method
checkHealth
checkHealth checks the health of the proxy origin.
proxy/health/health.go:65
↓ 1 callers
Method
ServeHTTP
ServeHTTP handles the incoming HTTP request and forwards it to the underlying proxy server. It increments the load counter by 1 before forwarding the
proxy/proxy.go:43
↓ 1 callers
Function
WithCheck
WithCheck sets the health check function for the proxy.
proxy/health/options.go:6
↓ 1 callers
Function
WithPeriodSeconds
WithPeriodSeconds sets the period for the health check.
proxy/health/options.go:13
↓ 1 callers
Function
checkURL
(a, b *url.URL)
weighted/weighted.go:162
↓ 1 callers
Function
defaultDNSCheck
defaultDNSCheck is a default health check function that checks if the DNS resolution to the address is successful.
proxy/health/health.go:180
↓ 1 callers
Function
defaultHTTPCheck
defaultHTTPCheck is a default health check function that checks if the HTTP connection to the address is successful.
proxy/health/health.go:140
↓ 1 callers
Function
defaultTCPCheck
defaultTCPCheck is a default health check function that checks if the TCP connection to the address is successful.
proxy/health/health.go:170
↓ 1 callers
Function
gcd
(a, b int)
weighted/weighted.go:166
↓ 1 callers
Method
run
()
proxy/health/health.go:92
↓ 1 callers
Method
stop
stop stops the currently rinning check func.
proxy/health/health.go:122
Method
AddServer
(url *url.URL, weight int)
weighted/weighted.go:89
Method
AddServers
AddServers adds the given servers to the roundrobin load balancer. It takes a variadic parameter of type *proxy.Proxy, representing the servers to be
roundrobin/roundrobin.go:65
Function
BenchmarkAddServers
(b *testing.B)
roundrobin/roundrobin_test.go:156
Function
BenchmarkNext
(b *testing.B)
roundrobin/roundrobin_test.go:124
Function
BenchmarkNext
(b *testing.B)
weighted/weighted_test.go:83
Function
BenchmarkNextParallel
(b *testing.B)
roundrobin/roundrobin_test.go:139
Function
BenchmarkRemoveServers
(b *testing.B)
roundrobin/roundrobin_test.go:172
Function
BenchmarkServers
(b *testing.B)
roundrobin/roundrobin_test.go:196
Function
ExampleRoundRobin
()
roundrobin/roundrobin_test.go:211
Function
ExampleRoundRobin
()
weighted/weighted_test.go:55
Method
GetLoading
GetLoading returns the current loading of the proxy.
proxy/proxy.go:50
Method
IsAvailable
IsAvailable returns whether the proxy origin was successfully connected at the last check time.
proxy/proxy.go:60
Method
NextServer
NextServer returns the next server in the rotation.
roundrobin/roundrobin.go:17
Method
NextServer
NextServer returns the next server in the round-robin algorithm. If there are no servers available, it returns nil. The server selection is based on a
roundrobin/roundrobin.go:47
Method
NextServer
while (true) { i = (i + 1) mod n; if (i == 0) { cw = cw - gcd(S); if (cw <= 0) { cw = max(S); if (cw == 0)
weighted/weighted.go:62
Method
RemoveAll
RemoveAll removes all servers from the load balancer.
roundrobin/roundrobin.go:29
Method
RemoveAll
RemoveAll removes all servers from the roundrobin load balancer. It resets both the server list and the rotation counter atomically.
roundrobin/roundrobin.go:142
Method
RemoveAll
()
weighted/weighted.go:136
Method
RemoveServer
(url *url.URL)
weighted/weighted.go:112
Method
RemoveServers
RemoveServers removes the specified servers from the roundrobin load balancer. It takes a variadic parameter 'names' which represents the names of the
roundrobin/roundrobin.go:81
Method
Reset
Reset resets all current weights.
weighted/weighted.go:26
Method
Reset
Reset resets all current weights.
weighted/weighted.go:146
Method
Servers
Servers returns a list of all servers in the load balancer.
roundrobin/roundrobin.go:26
Method
Servers
Servers returns a copy of all servers in the roundrobin load balancer. It returns a new slice to prevent external modifications to the internal state.
roundrobin/roundrobin.go:130
Method
Servers
()
weighted/weighted.go:125
Function
TestAddServers
(t *testing.T)
roundrobin/roundrobin_test.go:29
Function
TestDefaultDNSCheck
(t *testing.T)
proxy/health/health_test.go:135
Function
TestDefaultHTTPCheck
(t *testing.T)
proxy/health/health_test.go:81
Function
TestDefaultTCPCheck
(t *testing.T)
proxy/health/health_test.go:48
Function
TestNextServer
(t *testing.T)
roundrobin/roundrobin_test.go:11
Function
TestProxyHealth_IsAvailable
(t *testing.T)
proxy/health/health_test.go:12
Function
TestProxyHealth_checkHealth
(t *testing.T)
proxy/health/health_test.go:168
Function
TestProxy_ServeHTTP
(t *testing.T)
proxy/proxy_test.go:10
Function
TestRemoveAll
(t *testing.T)
roundrobin/roundrobin_test.go:62
Function
TestRemoveServer
(t *testing.T)
weighted/weighted_test.go:31
Function
TestRemoveServers
(t *testing.T)
roundrobin/roundrobin_test.go:100
Function
TestServers
(t *testing.T)
roundrobin/roundrobin_test.go:78
Function
WithInitialDelaySeconds
WithInitialDelaySeconds sets the initial delay for the health check.
proxy/health/options.go:20
Function
main
()
_example/roundrobin/main.go:10
Function
main
()
_example/weighted/main.go:15