-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduce entity that will keep info about services current state and integrate it into DASer and Syncer #725
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,25 @@ | ||||||
package service | ||||||
|
||||||
import "sync/atomic" | ||||||
|
||||||
type State uint32 | ||||||
|
||||||
const ( | ||||||
Stopped State = iota | ||||||
Running | ||||||
) | ||||||
|
||||||
// Service provides an interface to change an check service state | ||||||
type Service struct { | ||||||
state uint32 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case storing and loading state will be more complex:
IMO, better to leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then maybe the naming of |
||||||
} | ||||||
|
||||||
// SetState allows to change service state | ||||||
func (s *Service) SetState(state State) { | ||||||
atomic.StoreUint32(&s.state, uint32(state)) | ||||||
} | ||||||
|
||||||
// State returns service current state | ||||||
func (s *Service) State() State { | ||||||
return State(atomic.LoadUint32(&s.state)) | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.