Skip to content

Commit

Permalink
Merge f7d8b76 into cced626
Browse files Browse the repository at this point in the history
  • Loading branch information
nolouch authored May 4, 2017
2 parents cced626 + f7d8b76 commit 96c4d69
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/api/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/unrolled/render"
)

const defaultStoreDownTime = time.Minute

type metaStore struct {
*metapb.Store
StateName string `json:"state_name"`
Expand Down Expand Up @@ -54,7 +56,7 @@ type storeInfo struct {
}

func newStoreInfo(store *metapb.Store, status *server.StoreStatus) *storeInfo {
return &storeInfo{
s := &storeInfo{
Store: &metaStore{
Store: store,
StateName: store.State.String(),
Expand All @@ -74,6 +76,10 @@ func newStoreInfo(store *metapb.Store, status *server.StoreStatus) *storeInfo {
Uptime: typeutil.NewDuration(status.GetUptime()),
},
}
if time.Now().Sub(status.LastHeartbeatTS) > defaultStoreDownTime {
s.Store.StateName = "Down"
}
return s
}

type storesInfo struct {
Expand Down

0 comments on commit 96c4d69

Please sign in to comment.