xputil

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRtError          = errors.New("")
	ErrNoRoutines       = fmt.Errorf("%wno routines loaded", ErrRtError)
	ErrInvalidRoutine   = fmt.Errorf("%winvalid routine name", ErrRtError)
	ErrDuplicateRoutine = fmt.Errorf("%wduplicate routine name", ErrRtError)
	ErrRoutineActive    = fmt.Errorf("%wroutine is active", ErrRtError)
)

Functions

func SetProcTitle

func SetProcTitle(title string) error

set process title in OS process table, max 16 char

Types

type BaseProcess

type BaseProcess struct {
	*BaseTasklet

	// process title as shown in OS process table
	ProcTitle string
	// contains filtered or unexported fields
}

func NewBaseProcess

func NewBaseProcess(log *xlog.Logger, tsk Tasklet) *BaseProcess

create new base process

func (*BaseProcess) InitManagement added in v0.3.8

func (pr *BaseProcess) InitManagement(
	ipipe, opipe *xpipe.Pipe, hnd CommandHandler)

initialize process management

func (*BaseProcess) SetSignal

func (pr *BaseProcess) SetSignal(sig os.Signal, fn SignalHandler)

add signal handler

func (*BaseProcess) Start

func (pr *BaseProcess) Start()

func (*BaseProcess) Stop added in v0.3.8

func (pr *BaseProcess) Stop()

type BaseRoutine

type BaseRoutine struct {
	*BaseTasklet
	Name string
	// contains filtered or unexported fields
}

func NewBaseRoutine

func NewBaseRoutine(tsk Tasklet) *BaseRoutine

func (*BaseRoutine) IsAlive

func (rt *BaseRoutine) IsAlive() bool

func (*BaseRoutine) Parent

func (rt *BaseRoutine) Parent() *RtManager

func (*BaseRoutine) Setup

func (rt *BaseRoutine) Setup(name string, rm *RtManager) error

func (*BaseRoutine) Start

func (rt *BaseRoutine) Start()

type BaseTasklet

type BaseTasklet struct {
	Log *xlog.Logger

	// error delay for execution loop
	ErrorDelay float64
	// contains filtered or unexported fields
}

func NewBaseTasklet added in v0.3.8

func NewBaseTasklet(log *xlog.Logger, tsk Tasklet) *BaseTasklet

func (*BaseTasklet) IsKillEvent

func (tl *BaseTasklet) IsKillEvent() bool

check if kill event is set

func (*BaseTasklet) IsTermEvent

func (tl *BaseTasklet) IsTermEvent() bool

check if terminate event is set

func (*BaseTasklet) Kill

func (tl *BaseTasklet) Kill()

kill tasklet execution

func (*BaseTasklet) SafeExecute added in v0.3.8

func (tl *BaseTasklet) SafeExecute(f func() error) bool

run function with error and panic handling

func (*BaseTasklet) Sleep

func (tl *BaseTasklet) Sleep(timeout float64) bool

non-blocking sleep

func (*BaseTasklet) Start

func (tl *BaseTasklet) Start()

start tasklet execution

func (*BaseTasklet) Stop

func (tl *BaseTasklet) Stop()

terminate then kill tasklet execution

type CommandHandler added in v0.3.6

type CommandHandler func(string) string

command handling callback function takes received command and return reply message

type Routine

type Routine interface {
	Setup(string, *RtManager) error
	Parent() *RtManager
	IsAlive() bool
	Start()
	Stop()
	Kill()
}

type RtManager

type RtManager struct {
	*BaseProcess

	// routines monitoring interval in sec
	MonInterval float64
	// delay to wait for routine terminate in sec
	TermDelay float64
	// contains filtered or unexported fields
}

func NewRtManager

func NewRtManager(log *xlog.Logger) *RtManager

func (*RtManager) AddRoutine

func (rm *RtManager) AddRoutine(
	name string, rt Routine, active bool) error

add new routine handler to manager

func (*RtManager) CheckRoutines

func (rm *RtManager) CheckRoutines() error

monitor routines and start/stop as per each routine status

func (*RtManager) DelRoutine

func (rm *RtManager) DelRoutine(name string) error

delete routine handler from manager

func (*RtManager) Execute

func (rm *RtManager) Execute() error

run manager operations

func (*RtManager) Initialize

func (rm *RtManager) Initialize() error

initialize manager

func (*RtManager) ListRoutines

func (rm *RtManager) ListRoutines() []string

return name list of all current loaded routines

func (*RtManager) RestartRoutine

func (rm *RtManager) RestartRoutine(name string) error

restart routine

func (*RtManager) StartRoutine

func (rm *RtManager) StartRoutine(name string) error

start routine

func (*RtManager) StopRoutine

func (rm *RtManager) StopRoutine(name string) error

stop routine

func (*RtManager) Terminate

func (rm *RtManager) Terminate() error

terminate manager

type SignalHandler

type SignalHandler func()

signal handling callback function

type Tasklet

type Tasklet interface {
	Initialize() error
	Execute() error
	Terminate() error
}

Jump to

Keyboard shortcuts

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