Documentation
¶
Overview ¶
Package service provides service primitives.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCleanupOnlyService ¶ added in v0.2202.0
func IsCleanupOnlyService(svc BackgroundService) bool
IsCleanupOnlyService checks whether a given service is a cleanup only service.
Types ¶
type BackgroundService ¶
type BackgroundService interface {
CleanupAble
// Name returns the service name.
Name() string
// Start starts the service.
Start() error
// Stop halts the service.
Stop()
// Quit returns a channel that will be closed when the service terminates.
Quit() <-chan struct{}
}
BackgroundService is a background service.
func NewCleanupOnlyService ¶
func NewCleanupOnlyService(svc CleanupAble, name string) BackgroundService
NewCleanupOnlyService wraps a service as a cleanup only service.
type BaseBackgroundService ¶
type BaseBackgroundService struct {
Logger *logging.Logger
// contains filtered or unexported fields
}
BaseBackgroundService is a base implementation of BackgroundService.
func NewBaseBackgroundService ¶
func NewBaseBackgroundService(name string) *BaseBackgroundService
NewBaseBackgroundService creates a new base background service implementation.
func (*BaseBackgroundService) Cleanup ¶
func (b *BaseBackgroundService) Cleanup()
Cleanup performs the service specific post-termination cleanup.
func (*BaseBackgroundService) Name ¶
func (b *BaseBackgroundService) Name() string
Name returns the service name.
func (*BaseBackgroundService) Quit ¶
func (b *BaseBackgroundService) Quit() <-chan struct{}
Quit returns a channel that will be closed when the service terminates.
func (*BaseBackgroundService) Start ¶
func (b *BaseBackgroundService) Start() error
Start starts the service.
type CleanupAble ¶
type CleanupAble interface {
// Cleanup performs the service specific post-termination cleanup.
Cleanup()
}
CleanupAble provides a Cleanup method.
func NewContextCleanup ¶
func NewContextCleanup(parent context.Context) (context.Context, CleanupAble)
NewContextCleanup makes a context and a CleanupAble that cancels it.
type Group ¶ added in v0.2505.0
type Group struct {
// contains filtered or unexported fields
}
Group is responsible for concurrently starting a group of services.
func NewGroup ¶ added in v0.2505.0
NewGroup creates a new service group with the given list of services.
type NamedService ¶ added in v0.2505.0
NamedService is a blocking service with an associated name.
type Service ¶ added in v0.2505.0
type Service interface {
// Serve runs the service and blocks until it completes, an error occurs,
// or the context is canceled.
Serve(ctx context.Context) error
}
Service is a blocking service.
func AsBlocking ¶ added in v0.2506.0
func AsBlocking(service BackgroundService) Service
AsBlocking transforms a background service into a blocking service.