diff options
author | Valery Piashchynski <[email protected]> | 2021-02-02 19:30:00 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-02 19:30:00 +0300 |
commit | 20a1a5d2eb26090e0eef0e6772330ee2a52526fa (patch) | |
tree | c282e18c20029f60a798576cb4fe47d2762ffba0 /internal/state.go | |
parent | 36f01dc035f42115fcfd3b77dc5df3098382cd9f (diff) | |
parent | 2bdf7fafa73cabf7cf63657a6b58f2a423ae0fcd (diff) |
Merge pull request #522 from spiral/fix/named_loggerv2.0.0-beta.22
bug(logger): Incorrect parsing of nested log levels
Diffstat (limited to 'internal/state.go')
-rwxr-xr-x | internal/state.go | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/internal/state.go b/internal/state.go index a14a6937..d208aeed 100755 --- a/internal/state.go +++ b/internal/state.go @@ -3,6 +3,8 @@ package internal import ( "fmt" "sync/atomic" + + "github.com/spiral/roadrunner/v2/pkg/states" ) // State represents WorkerProcess status and updated time. @@ -24,36 +26,6 @@ type State interface { LastUsed() uint64 } -const ( - // StateInactive - no associated process - StateInactive int64 = iota - - // StateReady - ready for job. - StateReady - - // StateWorking - working on given payload. - StateWorking - - // StateInvalid - indicates that WorkerProcess is being disabled and will be removed. - StateInvalid - - // StateStopping - process is being softly stopped. - StateStopping - - StateKilling - - // State of worker, when no need to allocate new one - StateDestroyed - - // StateStopped - process has been terminated. - StateStopped - - // StateErrored - error WorkerState (can't be used). - StateErrored - - StateRemove -) - type WorkerState struct { value int64 numExecs uint64 @@ -69,17 +41,17 @@ func NewWorkerState(value int64) *WorkerState { // String returns current WorkerState as string. func (s *WorkerState) String() string { switch s.Value() { - case StateInactive: + case states.StateInactive: return "inactive" - case StateReady: + case states.StateReady: return "ready" - case StateWorking: + case states.StateWorking: return "working" - case StateInvalid: + case states.StateInvalid: return "invalid" - case StateStopped: + case states.StateStopped: return "stopped" - case StateErrored: + case states.StateErrored: return "errored" } @@ -99,7 +71,7 @@ func (s *WorkerState) Value() int64 { // IsActive returns true if WorkerProcess not Inactive or Stopped func (s *WorkerState) IsActive() bool { val := s.Value() - return val == StateWorking || val == StateReady + return val == states.StateWorking || val == states.StateReady } // change WorkerState value (status) |