Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrRunFnMustBeSpecified = errors.New("runFn must be specified") ErrNotStarted = errors.New("service not started") )
Functions ¶
This section is empty.
Types ¶
type BaseService ¶
type BaseService struct { Logger log.StandardLogger // Err is an error or multiple errors combined using `go.uber.org/multierr` that occurred during the service lifecycle. Err error // contains filtered or unexported fields }
BaseService is the base implementation of Service which can be embedded in actual services.
func NewBaseService ¶
func NewBaseService(runFn goprocess.ProcessFunc, stopFn goprocess.TeardownFunc, waits []Service, logger log.StandardLogger) (*BaseService, error)
NewBaseService creates a new BaseService.
func (*BaseService) EnsureChild ¶
func (s *BaseService) EnsureChild(child Service) error
func (*BaseService) Process ¶
func (s *BaseService) Process() goprocess.Process
func (*BaseService) Start ¶
func (s *BaseService) Start(parent Service)
func (*BaseService) StartChild ¶
func (s *BaseService) StartChild(child Service) error
func (*BaseService) Stop ¶
func (s *BaseService) Stop() error
func (*BaseService) WaitFor ¶
func (s *BaseService) WaitFor(other Service)
type Service ¶
type Service interface { // Start the service, optionally with a parent service. Start(parent Service) // Stop the service, return the error from the teardown function. Stop() error // StartChild starts a child service which will stop before this service stops when this service's Stop() is called. StartChild(child Service) error // EnsureChild starts a child service which will stop before this service stops when this service's Stop() is called. // If any child service started with EnsureChild stops, this service will stop all children then stop itself as well. EnsureChild(child Service) error // WaitFor makes the service wait for `other` before stopping. WaitFor(other Service) // Process returns the underlying goprocess, use with caution. Process() goprocess.Process }
Service is a goprocess-based service interface
Click to show internal directories.
Click to hide internal directories.