Change Server API

This commit is contained in:
Ken Hibino
2021-03-20 17:16:44 -07:00
parent af6d9d3df7
commit 5af86a0903
8 changed files with 46 additions and 46 deletions

View File

@@ -233,27 +233,27 @@ const (
// StatusIdle indicates the server is in idle state.
StatusIdle ServerStatusValue = iota
// StatusRunning indicates the server is up and active.
StatusRunning
// StatusActive indicates the server is up and active.
StatusActive
// StatusQuiet indicates the server is up but not active.
StatusQuiet
// StatusStopped indicates the server server has been stopped.
// StatusStopped indicates the server is up but no longer processing new tasks.
StatusStopped
// StatusClosed indicates the server has been shutdown.
StatusClosed
)
var statuses = []string{
"idle",
"running",
"quiet",
"active",
"stopped",
"closed",
}
func (s *ServerStatus) String() string {
s.mu.Lock()
defer s.mu.Unlock()
if StatusIdle <= s.val && s.val <= StatusStopped {
if StatusIdle <= s.val && s.val <= StatusClosed {
return statuses[s.val]
}
return "unknown status"

View File

@@ -544,7 +544,7 @@ func TestStatusConcurrentAccess(t *testing.T) {
wg.Add(1)
go func() {
defer wg.Done()
status.Set(StatusStopped)
status.Set(StatusClosed)
_ = status.String()
}()