service

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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

func NewService(name string, enabled bool) *Service

NewService creates a pointer to a new Service struct with the provided values.

func (*Service) GetName

func (service *Service) GetName() string

GetName returns the name of the service.

func (*Service) Health added in v0.3.0

func (service *Service) Health() error

Health returns nil if the service is healthy, otherwise returns the last error

func (*Service) IsEnabled

func (service *Service) IsEnabled() bool

IsEnabled returns true if the service is allowed to run.

func (*Service) IsRunning

func (service *Service) IsRunning() bool

IsRunning returns true if the service is currently running.

func (*Service) Run added in v0.3.0

func (service *Service) Run(wg *sync.WaitGroup)

Run is the main thread of the process, called as a goroutine.

func (*Service) Start

func (service *Service) Start(wg *sync.WaitGroup) error

Start spawns all processes done by the service.

func (*Service) Stop

func (service *Service) Stop() error

Stop terminates all processes belonging to the service, blocking until they are all terminated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL