generalized store state

This commit is contained in:
Matthias Hannig 2017-06-23 16:41:14 +02:00
parent 57aed13e0f
commit 93f0047945
2 changed files with 25 additions and 6 deletions

View File

@ -9,12 +9,6 @@ import (
"time"
)
type StoreStatus struct {
LastRefresh time.Time
LastError error
State int
}
type RoutesStore struct {
routesMap map[sources.Source]api.RoutesResponse
statusMap map[sources.Source]StoreStatus

View File

@ -1,8 +1,33 @@
package main
import (
"time"
)
const (
STATE_INIT = iota
STATE_READY
STATE_UPDATING
STATE_ERROR
)
type StoreStatus struct {
LastRefresh time.Time
LastError error
State int
}
// Helper: stateToString
func stateToString(state int) string {
switch state {
case STATE_INIT:
return "INIT"
case STATE_READY:
return "READY"
case STATE_UPDATING:
return "UPDATING"
case STATE_ERROR:
return "ERROR"
}
return "INVALID"
}