workermanager

package
v0.0.0-...-f9d70ec Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GracefulExitCode exit normally code
	GracefulExitCode = 0

	// ForceTimeoutExitCode timeout exit code
	ForceTimeoutExitCode = 1
)

Variables

This section is empty.

Functions

func TryCatch

func TryCatch(f Worker)

TryCatch start service

Types

type Worker

type Worker interface {
	Start()
	Stop()
	GetProcessName() string
}

Worker working external interface

type WorkerManager

type WorkerManager struct {
	sync.WaitGroup
	WorkerSlice []Worker
	Running     bool
	Q           chan os.Signal
	Ctx         context.Context
	CtxCancel   context.CancelFunc
}

WorkerManager working concrete implementation class

func NewWorkerManager

func NewWorkerManager() *WorkerManager

NewWorkerManager initialization WorkerManager class

func (*WorkerManager) AddWorker

func (wm *WorkerManager) AddWorker(w Worker)

AddWorker add worker and start service

func (*WorkerManager) AddWorkerList

func (wm *WorkerManager) AddWorkerList(w []Worker)

AddWorkerList add workers and start service

func (*WorkerManager) MakeRecvSignal

func (wm *WorkerManager) MakeRecvSignal() os.Signal

MakeRecvSignal receive user signals

func (*WorkerManager) MakeSignal

func (wm *WorkerManager) MakeSignal()

MakeSignal semaphores are currently supported

func (*WorkerManager) RecvSignal

func (wm *WorkerManager) RecvSignal() os.Signal

RecvSignal receive signal

func (*WorkerManager) Start

func (wm *WorkerManager) Start()

Start start all service

func (*WorkerManager) Stop

func (wm *WorkerManager) Stop()

Stop stop all service

func (*WorkerManager) WaitTimeout

func (wm *WorkerManager) WaitTimeout(timeout int) int

WaitTimeout close channel and exit

Jump to

Keyboard shortcuts

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