-
Notifications
You must be signed in to change notification settings - Fork 0
/
lister.go
49 lines (39 loc) · 1.56 KB
/
lister.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package stargate
import (
"net/http"
"time"
)
const (
DefaultHealthCheckPath = "/"
DefaultHealthCheckStatus = http.StatusOK
DefaultHealthCheckInterval = 30 * time.Second
DefaultHealthCheckTimeout = 10 * time.Second
DefaultHealthyPings = 3
DefaultUnhealthyPings = 3
)
// RouteOptions defines the configuration of a route.
type RouteOptions struct {
// Address is the absolute address of an origin server.
Address string
// HealthCheck indicates that a health checker routine is to spawned, if not nil.
HealthCheck *HealthCheckOptions
}
// HealthCheckOptions defines the behavior of the health checker routine.
type HealthCheckOptions struct {
// Path is the relative path on the origin server that is to be used for health checking. Defaults to "/".
Path string
// Interval is the frequency of health checks. Defaults to 30s.
Interval time.Duration
// Timeout dictates how long Stargate should wait for a health check ping to finish. Defaults to 10s.
Timeout time.Duration
// HealthyStatus is the expected status code of a successful health check ping. Defaults to http.StatusOK.
HealthyStatus int
// UnhealthyPings represents the number of unsuccessful healthcheck calls after which the origin server is deemed
// unhealthy. Once an origin is deemed unhealthy, it must pass UnhealthyPings pings to be considered healthy again.
UnhealthyPings int
}
// ServiceLister provides all available routes and their downstream services
type ServiceLister interface {
List(string) ([]*RouteOptions, error)
ListAll() (map[string][]*RouteOptions, error)
}