servicing

package
v0.0.0-...-1185af5 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package servicing provides synchronization, error propagation, and Context cancellation for groups of services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GracefulShutdownFunc

type GracefulShutdownFunc func(ctx context.Context)

GracefulShutdownFunc function used to close all opened connections gracefully.

type Service

type Service interface {
	WithShutdownSignal(shutdown <-chan struct{}, done chan<- struct{}) Service
	Start() error
	Name() string
	Addr() string
}

Service is an interface used by ServiceGroup.

type ServiceGroup

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

ServiceGroup manages services start and graceful shutdown synchronize.

func WithGracefulSutDown

func WithGracefulSutDown(gracefulShutdownFuncs ...GracefulShutdownFunc) *ServiceGroup

WithGracefulSutDown returns a new ServiceGroup with GracefulShutdownFunc functions.

func (*ServiceGroup) Close

func (sg *ServiceGroup) Close() (err error)

Close invokes services to termination.

func (*ServiceGroup) Start

func (sg *ServiceGroup) Start(ctx context.Context, log func(ctx context.Context, msg string), srvs ...Service) error

Start starts services synchronize and blocks until all services finishes by a notify signal.

Returns error in case any of the services fail to starting.

Jump to

Keyboard shortcuts

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