Loggest thine Stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
1.1 KiB

package models
type Status int
func (s Status) Valid() bool {
return s >= 0 && s < maxStatus
}
func (s Status) Name() string {
if s < 0 || s >= maxStatus {
return "(invalid status)"
}
return StatusLabels[s]
}
func (s Status) Less(s2 Status) bool {
if s == Active && s2 != Active {
return true
}
if s != Active && s2 == Active {
return false
}
if s == Background && s2 != Background {
return true
}
if s != Background && s2 == Background {
return false
}
if s == Available && s2 != Available {
return true
}
if s != Available && s2 == Available {
return false
}
if s == Blocked && s2 != Blocked {
return true
}
if s != Blocked && s2 == Blocked {
return false
}
return s < s2
}
func (s Status) Ended() bool {
switch s {
case Completed, Failed, Dropped:
return true
default:
return false
}
}
const (
Blocked Status = iota
Available
Background
Active
Completed
Failed
Dropped
maxStatus
)
var StatusLabels = map[Status]string{
Blocked: "Blocked",
Available: "Available",
Background: "Background",
Active: "Active",
Completed: "Completed",
Failed: "Failed",
Dropped: "Dropped",
}