We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 64026b3 commit 59210a2Copy full SHA for 59210a2
1 file changed
api/upstream.go
@@ -21,6 +21,10 @@ func (r *roundrobin) get() string {
21
r.Lock()
22
defer r.Unlock()
23
24
+ if len(r.pool) == 0 {
25
+ return ""
26
+ }
27
+
28
if r.current >= len(r.pool) {
29
r.current %= len(r.pool)
30
}
@@ -32,6 +36,12 @@ func (r *roundrobin) get() string {
32
36
33
37
// Modified BalancerForward to add upstream server to fiber context
34
38
func BalancerForward(servers []string, clients ...*fasthttp.Client) fiber.Handler {
39
+ if len(servers) == 0 {
40
+ return func(c *fiber.Ctx) error {
41
+ return c.SendStatus(fiber.StatusServiceUnavailable)
42
43
44
35
45
r := &roundrobin{
46
current: 0,
47
pool: servers,
0 commit comments