servicegroup

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTerminatedNotifier

func NewTerminatedNotifier() chan struct{}

NewTerminatedNotifier creates a channel which can be used to listen to its being closed

Types

type ManagedService

type ManagedService interface {
	//Start starts a server which waits on close of the interrupt channel and modifies the wg
	Start(interrupt chan struct{}, wg *sync.WaitGroup)
	//GetTerminationNotifier returns a channel which will be closed on termination of the service
	GetTerminationNotifier() chan struct{}

	//GetInterrupt returns a interrupt channel set during construction
	GetInterrupt() chan struct{}
}

ManagedService is a service which can be lifecycle managed

func NewManagedService

func NewManagedService(log logr.Logger, service Service, terminated chan struct{}, interrupt chan struct{}) ManagedService

NewManagedService creates a managed service with an optional interrupt channel

type ManagedServiceGroup

type ManagedServiceGroup interface {
	//Start starts all registered services
	Start()
	//GetTerminationNotfier returns a channel which will be closed on termination of all services
	GetTerminationNotfier() chan struct{}
	//Wait blocks until all services are terminated
	Wait()
}

ManagedServiceGroup defines a ManagedServiceGroup

func NewManagedServiceGroup

func NewManagedServiceGroup(interrupt chan struct{}, terminated chan struct{}, services ...ManagedService) ManagedServiceGroup

NewManagedServiceGroup creates a new service group

type Service

type Service interface {
	Start() error
	Shutdown(ctx context.Context) error
	String() string
}

Service defines a Service which can be Started and Shutdown

Jump to

Keyboard shortcuts

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