common: comments for Service

This commit is contained in:
Ethan Buchman 2017-11-29 05:16:15 +00:00
parent ddd141c1c5
commit 4d991acae0
1 changed files with 11 additions and 0 deletions

View File

@ -13,18 +13,29 @@ var (
ErrAlreadyStopped = errors.New("already stopped")
)
// Service defines a service that can be started, stopped, and reset.
type Service interface {
// Start the service.
// If it's already started or stopped, will return an error.
// If OnStart() returns an error, it's returned by Start()
Start() error
OnStart() error
// Stop the service.
// If it's already stopped, will return an error.
// OnStop must never error.
Stop() error
OnStop()
// Reset the service.
// Panics by default - must be overwritten to enable reset.
Reset() error
OnReset() error
// Return true if the service is running
IsRunning() bool
// String representation of the service
String() string
SetLogger(log.Logger)