Documentation
¶
Index ¶
- Constants
- Variables
- type IService
- type IServiceManager
- type Service
- func (service *Service) GetName() string
- func (service *Service) Health() error
- func (service *Service) IsEnabled() bool
- func (service *Service) IsRunning() bool
- func (service *Service) Run(wg *sync.WaitGroup)
- func (service *Service) Start(wg *sync.WaitGroup) error
- func (service *Service) Stop() error
Constants ¶
View Source
const ( // MsgServiceInitializing message to return when service is initializing. MsgServiceInitializing = " service initializing..." // MsgServiceInitialized message to return when service has initialized. MsgServiceInitialized = " service initializing... Success." // MsgServiceStarting message to return when service is starting up. MsgServiceStarting = " service starting..." // MsgServiceStarted message to return when service has started. MsgServiceStarted = " service starting... Success." // MsgServiceShuttingDown message to return when a service is shutting down. MsgServiceShuttingDown = " service shutting down..." // MsgServiceShutdown message to return when a service has shutdown. MsgServiceShutdown = " service shutting down ... Success" )
Variables ¶
View Source
var ( // ErrServiceAlreadyStarted message to return when a service is called to start but is already running. ErrServiceAlreadyStarted = errors.New("service already started") // ErrServiceAlreadyStopped message to return when a service is called to stop but is already stopped. ErrServiceAlreadyStopped = errors.New("service already stopped") // ErrNilService is returned when service functions are called but the service is not instantiated. ErrNilService = errors.New("service not setup") // ErrServiceNotEnabled is returned when a service is called to start but is not enabled. ErrServiceNotEnabled = errors.New("service not enabled") // ErrSubsystemNotEnabled is returned when a subsystem can't be found ErrSubsystemNotEnabled = errors.New("subsystem not enabled") // ErrServiceNotFound is returned when a service can not be found. ErrServiceNotFound = errors.New("service not found") // ErrServiceNilWaitGroup is returned when a service has nil wait group. ErrServiceNilWaitGroup = errors.New("service nil wait group received") )
Functions ¶
This section is empty.
Types ¶
type IService ¶
type IService interface {
// Start spawns all processes done by the service.
Start(wg *sync.WaitGroup) error
// Run is the main thread of the process, called as a goroutine.
Run(wg *sync.WaitGroup)
// Stop terminates all processes belonging to the service, blocking until they are all terminated.
Stop() error
// IsRunning returns true if the service is currently running.
IsRunning() bool
// IsEnabled returns true if the service is allowed to run.
IsEnabled() bool
// GetName returns the name of the service.
GetName() string
// Health returns nil if the service is healthy, otherwise returns the last error
Health() error
}
IService exports an interface that is implemented by each Service. This is used by the implementation of the subsystem manager in the engine.
type IServiceManager ¶ added in v0.3.0
type IServiceManager interface {
SetService(name string, status bool)
GetService(name string) bool
}
IServiceManager exports an interface that is implemented by the engine to manage all services
type Service ¶
type Service struct {
Shutdown chan struct{}
// contains filtered or unexported fields
}
Service is the base type for all services defined in the project.
func NewService ¶
NewService creates a pointer to a new Service struct with the provided values.
func (*Service) Health ¶ added in v0.3.0
Health returns nil if the service is healthy, otherwise returns the last error
Click to show internal directories.
Click to hide internal directories.