|
@ -14,6 +14,11 @@ var ( |
|
|
errAlreadyStopped = errors.New("already stopped") |
|
|
errAlreadyStopped = errors.New("already stopped") |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
|
|
_ Service = (*BaseService)(nil) |
|
|
|
|
|
_ Service = (*NopService)(nil) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// Service defines a service that can be started, stopped, and reset.
|
|
|
// Service defines a service that can be started, stopped, and reset.
|
|
|
type Service interface { |
|
|
type Service interface { |
|
|
// Start is called to start the service, which should run until
|
|
|
// Start is called to start the service, which should run until
|
|
@ -85,6 +90,12 @@ type BaseService struct { |
|
|
impl Implementation |
|
|
impl Implementation |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type NopService struct{} |
|
|
|
|
|
|
|
|
|
|
|
func (NopService) Start(_ context.Context) error { return nil } |
|
|
|
|
|
func (NopService) IsRunning() bool { return true } |
|
|
|
|
|
func (NopService) Wait() {} |
|
|
|
|
|
|
|
|
// NewBaseService creates a new BaseService.
|
|
|
// NewBaseService creates a new BaseService.
|
|
|
func NewBaseService(logger log.Logger, name string, impl Implementation) *BaseService { |
|
|
func NewBaseService(logger log.Logger, name string, impl Implementation) *BaseService { |
|
|
return &BaseService{ |
|
|
return &BaseService{ |
|
|