Skip to content

Commit

Permalink
Log upstream check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sammy007 committed Dec 30, 2015
1 parent 442e847 commit 47e4f92
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ func (s *ProxyServer) checkUpstreams() {
backup := false

for i, v := range s.upstreams {
if v.Check() && !backup {
ok, err := v.Check()
if err != nil {
log.Printf("Upstream %v didn't pass check: %v", v.Name, err)
}
if ok && !backup {
candidate = int32(i)
backup = true
}
Expand Down
6 changes: 3 additions & 3 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func (r *RPCClient) doPost(url, method string, params interface{}) (JSONRpcResp,
return rpcResp, err
}

func (r *RPCClient) Check() bool {
func (r *RPCClient) Check() (bool, error) {
_, err := r.GetWork()
if err != nil {
return false
return false, err
}
r.markAlive()
return !r.Sick()
return !r.Sick(), nil
}

func (r *RPCClient) Sick() bool {
Expand Down

0 comments on commit 47e4f92

Please sign in to comment.