Documentation ¶
Overview ¶
Package service provides helpers for long-running service applications.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
A Service is a service provided by a number of goroutines which will initiate a graceful shutdown when either one of those goroutines errors, or on the receipt of chosen signals.
func NewService ¶
NewService creates a new service instance using the given context. If any signals are specified the service will start a shutdown upon receiving that signal.
func (*Service) Go ¶
Go calls the given function in a new goroutine.
The first call to return a non-nil error cancels the service; its error will be returned by Wait.
func (*Service) OnShutdown ¶
func (s *Service) OnShutdown(f func())
OnShutdown registers a function to be called when the service determines it is shutting down. The Wait function will wait for all functions provided to OnShutdown to complete before returning.
type SignalError ¶
A SignalError is the type of error returned when a Service has shutdown due to receiving a signal.
func (*SignalError) Error ¶
func (e *SignalError) Error() string
Error implements the error interface.