diff options
author | Valery Piashchynski <[email protected]> | 2021-02-02 19:17:03 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-02-02 19:17:03 +0300 |
commit | 2bdf7fafa73cabf7cf63657a6b58f2a423ae0fcd (patch) | |
tree | fe5efc14a18f78218816a2bc7a2e19ee95642714 /internal/state.go | |
parent | 68becf8c58daec426f94513cf444061c199194d7 (diff) |
Move worker states out of internal
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) |