Skip to content

Commit

Permalink
Return http 100 before sync is complete
Browse files Browse the repository at this point in the history
  • Loading branch information
sttts committed Feb 26, 2015
1 parent bd08c5c commit 34e5ca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
)

const (
SYNCED_STATE = "4"
JOINING_STATE = "1"
DONOR_DESYNCED_STATE = "2"
JOINED_STATE = "3"
SYNCED_STATE = "4"
)

type Healthchecker struct {
Expand Down Expand Up @@ -34,7 +36,9 @@ func (h *Healthchecker) Check() (bool, string) {
switch {
case err != nil:
return false, err.Error()
case value == SYNCED_STATE || (value == DONOR_DESYNCED_STATE && h.config.AvailableWhenDonor):
case value == JOINING_STATE || value == DONOR_DESYNCED_STATE || value == JOINED_STATE:
return true, "syncing"
case value == SYNCED_STATE:
if !h.config.AvailableWhenReadOnly {
var ro_variable_name string
var ro_value string
Expand Down
6 changes: 5 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ var healthchecker *healthcheck.Healthchecker
func handler(w http.ResponseWriter, r *http.Request) {
result, msg := healthchecker.Check()
if result {
w.WriteHeader(http.StatusOK)
if msg == "syncing" {
w.WriteHeader(http.StatusContinue)
} else {
w.WriteHeader(http.StatusOK)
}
} else {
w.WriteHeader(http.StatusServiceUnavailable)
}
Expand Down

0 comments on commit 34e5ca0

Please sign in to comment.