runner

package
v1.9.18 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 9 Imported by: 0

README

Ранер.

Компонент позволяет запускать таски в отдельных го рутинах.

Интерфейс доустпный в контейнере объъктов

type Runner interface {
	io.Closer
	AddProcesses(processes ...Process) error
}

Метод AddProcesses принимает список тасок для запуска. Таски должны реализовывать интерфейс Process

type Process interface {
	Process(ctx context.Context) error
	Name() string
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Component = &app.Component{
	Dependencies: app.Components{
		logger.Component,
	},
	Constructor: func(container container.Container) error {
		return container.Provide(New)
	},
	ServeChan: app.ServeChan(func(container container.Container, isServeChan chan struct{}) error {
		return container.Invoke(func(runner Runner, closer closer.Closer, informer logger.Informer) error {
			ctx, cancelFunc := context.WithCancel(closer.GetContext())
			defer cancelFunc()

			informer.Info("runner: started")

			isServeChan <- struct{}{}
			<-ctx.Done()

			informer.Info("runner: shutdown")

			return runner.Close()
		})
	}),
}

Functions

This section is empty.

Types

type Process

type Process interface {
	Process(ctx context.Context) error
	Name() string
}

type Runner

type Runner interface {
	io.Closer
	AddProcesses(processes ...Process) error
}

func New

func New(logger logger.Logger, closer closer.Closer) Runner

Jump to

Keyboard shortcuts

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