From 4d991acae0f0eb0ebfab14eabb55e18854c5a2a2 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 29 Nov 2017 05:16:15 +0000 Subject: [PATCH] common: comments for Service --- common/service.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/service.go b/common/service.go index 608f8b722..d70d16a80 100644 --- a/common/service.go +++ b/common/service.go @@ -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)