service

package
v0.0.0-...-8993a07 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Enabler

type Enabler interface {
	Enabled() bool
}

Enabler allows check that service enabled.

type Group

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

Group allows to provide runner of services.

func (*Group) Name

func (g *Group) Name() string

Name used to implement Service interface.

func (*Group) Services

func (g *Group) Services() []Service

Services return multiple services.

func (*Group) Start

func (g *Group) Start(context.Context) error

Start used to implement Service interface.

func (*Group) Stop

func (g *Group) Stop(context.Context)

Stop used to implement Service interface.

type Launcher

type Launcher func(context.Context) error

Launcher function that will be called on start.

type Option

type Option func(*runner)

Option allows customizing service module.

func WithIgnoreError

func WithIgnoreError(v error) Option

WithIgnoreError allows set ignored errors.

func WithLoggerPingPong

func WithLoggerPingPong(v time.Duration) Option

WithLoggerPingPong allows to set ping-pong timer for logger.

func WithService

func WithService(v Service) Option

WithService allows set Service into Runner.

func WithShutdownTimeout

func WithShutdownTimeout(v time.Duration) Option

WithShutdownTimeout allows set shutdown timeout.

type Runner

type Runner interface {
	Run(context.Context) error
}

Runner collects services and runs them concurrently. - when any service returns, all services will be stopped. - when context canceled or deadlined all services will be stopped.

func New

func New(log logger.Logger, options ...Option) Runner

New creates and configures Runner by passed Option's.

type Service

type Service interface {
	Name() string
	Start(context.Context) error
	Stop(context.Context)
}

Service interface for component that should be run as goroutine.

func NewGroup

func NewGroup(name string, services ...Service) Service

NewGroup returns a group of services.

func NewWorker

func NewWorker(name string, call Launcher) Service

NewWorker creates Service implementation for worker.

Jump to

Keyboard shortcuts

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