@ -1,6 +1,7 @@
package check
import (
"encoding/json"
"time"
)
@ -32,3 +33,19 @@ func statusFromSuccessCount(count int) Result {
func divide(t time.Duration, dividend int) time.Duration {
return time.Duration(int(t) / dividend)
}
func (r Result) String() string {
switch r {
case Online:
return "online"
case Unstable:
return "unstable"
case Offline:
return "offline"
panic("Unexpected value")
func (r Result) MarshalJSON() ([]byte, error) {
return json.Marshal(r.String())