iservices

package
v1.202405300917.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAtLeastOneServiceFailedToStart = errors.New("at least one service failed to start")

Functions

func WiredStructPtrToMap

func WiredStructPtrToMap(addresOfWiredStruct interface{}) (res map[string]IService)

Extract IService fields of a struct which is supposed to be a result of wire to a map[string]IService

Types

type IService

type IService interface {
	Prepare() (err error)
	Run(ctx context.Context)
}

type IServicesController

type IServicesController interface {
	// PrepareAndRun services (IService) in separate goroutines
	// If any service fails then
	//   Run() is called with cancelled context for every started service
	//   errors.Is(ErrAtLeastOneServiceFailedToStart, err)
	// If all servies are ok join() should be called to join services
	// join() waits ctx and then waits for all services
	PrepareAndRun(ctx context.Context, services map[string]IService) (join func(ctx context.Context), err error)
}

IServiceFactory is a factory for IService

Jump to

Keyboard shortcuts

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