service

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MsgServiceInitializing message to return when subsystem is initializing.
	MsgServiceInitializing = " subsystem initializing..."

	// MsgServiceInitialized message to return when subsystem has initialized.
	MsgServiceInitialized = " subsystem initializing... Success."

	// MsgServiceStarting message to return when subsystem is starting up.
	MsgServiceStarting = " subsystem starting..."

	// MsgServiceStarted message to return when subsystem has started.
	MsgServiceStarted = " subsystem starting... Success."

	// MsgServiceShuttingDown message to return when a subsystem is shutting down.
	MsgServiceShuttingDown = " subsystem shutting down..."

	// MsgServiceShutdown message to return when a subsystem has shutdown.
	MsgServiceShutdown = " subsystem 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")

	// ErrServiceNotStarted message to return when service not started.
	ErrServiceNotStarted = errors.New("service not started")

	// 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")

	// ErrServiceNotInitialized is returned when a service is called to start but has not been initialized.
	ErrServiceNotInitialized = errors.New("service not initialized")

	// 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)

	// 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
}

IService exports an interface to the Service type.

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 subsystems name

func (*Service) IsEnabled

func (service *Service) IsEnabled() bool

IsEnabled checks whether the service is enabled or not

func (*Service) IsRunning

func (service *Service) IsRunning() bool

IsRunning checks whether the service is running

func (*Service) Start

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

Start is the main process for the service, run as a goroutine in the provided WaitGroup

func (*Service) Stop

func (service *Service) Stop() error

Stop The function to stop the service

Jump to

Keyboard shortcuts

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