Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultErrorCallback(err *Error)
- func DefaultExitCodeGetter(err *Error) int
- func DefaultSignalCallback(sig os.Signal) bool
- func LogErrorCallback(log *log.Logger) func(err *Error)
- func SystemdNotify(state string) error
- type Error
- type ErrorType
- type Option
- func ErrorCallback(callback func(err *Error)) Option
- func ExitCodeGetter(exitCodeGetter func(err *Error) int) Option
- func OnClosed(callback func(s Service, l lifecycle.Lifecycle)) Option
- func OnStarted(callback func(s Service, l lifecycle.Lifecycle)) Option
- func SignalNotify(callback func(sig os.Signal) (exit bool), sig ...os.Signal) Option
- func WithNotify(notify bool) Option
- type Service
Constants ¶
View Source
const ( // StartError is the type of error returned by the Start method of Lifecycle StartError = ErrorType(iota) // ExitError is the type of error returned by the Run method of Lifecycle ExitError // StopError is the type of error returned by the Close method of Lifecycle StopError // ServiceError is the type of system service error ServiceError )
Variables ¶
Functions ¶
func DefaultErrorCallback ¶
func DefaultErrorCallback(err *Error)
func DefaultExitCodeGetter ¶
func DefaultSignalCallback ¶
func LogErrorCallback ¶
func SystemdNotify ¶
SystemdNotify function notify service manager about start-up completion and other service status changes
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures a Service.
func ErrorCallback ¶
ErrorCallback Option specifies the callback function for the Service when an error occurs
func ExitCodeGetter ¶
ExitCodeGetter Option specifies the callback function for the Service to obtain the program exit code
func SignalNotify ¶
SignalNotify Option specifies the callback function when capturing the signal to be notified, if callback return true, If the callback function returns true, the program will start to exit
func WithNotify ¶
type Service ¶
type Service interface { // Run method is the main function of program running. The Run method // needs to include the implementation of notifying the system service // daemon(e.g. linux systemd or Windows service manager) when the // program starts, exits, or has errors Run() (exitCode int) }
Service interface specifies the behavior of the system service
Source Files ¶
Click to show internal directories.
Click to hide internal directories.