service

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyRunning = errors.New("Service already running")

Functions

func Group

func Group(services ...Service) *serviceGroup

func LazyService

func LazyService(name string, factory func() (Service, error)) *lazyService

func RunServices

func RunServices(ctx context.Context, services ...Service) error

Types

type ErrorCollector

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

func NewErrorCollector

func NewErrorCollector() *ErrorCollector

func (*ErrorCollector) Add

func (ec *ErrorCollector) Add(err error)

func (*ErrorCollector) Error

func (ec *ErrorCollector) Error() error

type RunningLock

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

func (*RunningLock) Disable

func (rl *RunningLock) Disable()

func (*RunningLock) EnableOrFail

func (rl *RunningLock) EnableOrFail() error

func (*RunningLock) Running

func (rl *RunningLock) Running() bool

type Service

type Service interface {
	// Name retrieves the name of the service, that will be used
	// to identify the service in log messages
	Name() string

	// Running indicates if the service is currently running
	Running() bool

	// Start runs the service and blocks until the service finishes,
	// returns an error when service failed
	Start(ctx context.Context) error
}

func WithDelay

func WithDelay(srv Service, delay time.Duration) Service

type ServiceManager

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

func NewServiceManager

func NewServiceManager(ctx context.Context) *ServiceManager

func (*ServiceManager) Add

func (sm *ServiceManager) Add(srv Service)

func (*ServiceManager) Wait

func (sm *ServiceManager) Wait() error

type ServieFactory

type ServieFactory func() (Service, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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