manager

package
v0.0.0-...-a3532f1 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Logger logger.Logger
}

type Service

type Service interface {
	Start() error
	Stop() error
}

Service defines the interface for a service with Start and Stop methods.

type ServiceController

type ServiceController interface {
	Add(name ServiceName, s Service) error
	Start() error
	Stop() error
}

ServiceController defines the interface for a service manager.

type ServiceManager

type ServiceManager struct {
	// contains filtered or unexported fields
}

ServiceManager is responsible for managing multiple services.

func New

func New(opts *Options) *ServiceManager

New creates and returns a new ServiceManager.

func (*ServiceManager) Add

func (sm *ServiceManager) Add(name ServiceName, s Service) error

Add adds a service to the ServiceManager. It returns an error if a Start or Stop operation is currently in progress.

func (*ServiceManager) Start

func (sm *ServiceManager) Start() error

Start starts all services concurrently. If any service fails to start, it stops the already started services and returns the error.

func (*ServiceManager) Stop

func (sm *ServiceManager) Stop() error

Stop stops all services concurrently. If any service fails to stop, it continues to stop other services and returns the error.

type ServiceName

type ServiceName string

ServiceName defines the type for a service name.

Jump to

Keyboard shortcuts

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