added ip_hash load balancing

updated tests

fixed comment format

fixed formatting, minor logic fix

added newline to EOF

updated logic, fixed tests

added comment

updated formatting

updated test output

fixed typo
This commit is contained in:
Kris Hamoud
2016-07-31 02:04:54 -07:00
parent 72af3f8256
commit 88d3dcae42
6 changed files with 189 additions and 29 deletions

View File

@ -27,7 +27,7 @@ type Upstream interface {
// The path this upstream host should be routed on
From() string
// Selects an upstream host to be routed to.
Select() *UpstreamHost
Select(*http.Request) *UpstreamHost
// Checks if subpath is not an ignored path
AllowedPath(string) bool
}
@ -93,7 +93,7 @@ func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
// hosts until timeout (or until we get a nil host).
start := time.Now()
for time.Now().Sub(start) < tryDuration {
host := upstream.Select()
host := upstream.Select(r)
if host == nil {
return http.StatusBadGateway, errUnreachable
}