Documentation
¶
Index ¶
- type CommandHandler
- type Process
- type Routine
- type RoutineHandler
- type RoutineManager
- func (m *RoutineManager) AddRoutine(name string, rt Routine, enabled bool) error
- func (m *RoutineManager) DelRoutine(name string) error
- func (m *RoutineManager) Execute() error
- func (m *RoutineManager) Initialize() error
- func (m *RoutineManager) ListRoutines() []string
- func (m *RoutineManager) RestartRoutine(name string) error
- func (m *RoutineManager) StartRoutine(name string) error
- func (m *RoutineManager) StopRoutine(name string) error
- func (m *RoutineManager) Terminate() error
- type Tasklet
- type TaskletHandler
- func (h *TaskletHandler) Disable()
- func (h *TaskletHandler) Enable()
- func (h *TaskletHandler) IsAlive() bool
- func (h *TaskletHandler) IsEnabled() bool
- func (h *TaskletHandler) IsInitialized() bool
- func (h *TaskletHandler) Kill()
- func (h *TaskletHandler) Run()
- func (h *TaskletHandler) Sleep(timeout float64) bool
- func (h *TaskletHandler) Start()
- func (h *TaskletHandler) Stop()
- func (h *TaskletHandler) WaitStop(timeout float64) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandHandler ¶
CommandHandler defines the function handling commands.
type Process ¶
type Process struct { *TaskletHandler // contains filtered or unexported fields }
Process manages OS signal handling in addition to Tasklet management.
func NewProcessHandler ¶
NewProcessHandler creates a new ProcessHandler with signal handlers for common signals like SIGINT and SIGTERM.
func (*Process) SetCmdHandler ¶
func (h *Process) SetCmdHandler(l comm.Listener, f CommandHandler)
SetCmdHandler sets the command handling function and comm listener to enable command handling feature on process.
func (*Process) SetSignalHandler ¶
SetSignalHandler allows the user to define custom handlers for specific signals.
type Routine ¶
type Routine interface { IsEnabled() bool IsAlive() bool IsInitialized() bool Enable() Disable() Start() Stop() Kill() }
Routine defines the methods that must be implemented by any routine managed by routine manager.
type RoutineHandler ¶
type RoutineHandler = TaskletHandler
func NewRoutineHandler ¶
func NewRoutineHandler(log *logging.Logger, tsk Tasklet) *RoutineHandler
type RoutineManager ¶
type RoutineManager struct { *Process // MonitoringInterval specifies the routines monitoring interval in sec. MonitoringInterval float64 // StoppingDelay specifies the duration to wait for routines to stop. StoppingDelay float64 // contains filtered or unexported fields }
RoutineManager manages the lifecycle of routines, allowing them to be started, stopped, and monitored.
func NewRoutineManager ¶
func NewRoutineManager(log *logging.Logger) *RoutineManager
New creates a new routine manager instance.
func (*RoutineManager) AddRoutine ¶
func (m *RoutineManager) AddRoutine(name string, rt Routine, enabled bool) error
AddRoutine adds a new routine to the routine manager.
func (*RoutineManager) DelRoutine ¶
func (m *RoutineManager) DelRoutine(name string) error
DelRoutine removes a routine from the routine manager.
func (*RoutineManager) Execute ¶
func (m *RoutineManager) Execute() error
Execute runs the routine check and waits for the specified monitor interval.
func (*RoutineManager) Initialize ¶
func (m *RoutineManager) Initialize() error
Initialize prepares the routine manager.
func (*RoutineManager) ListRoutines ¶
func (m *RoutineManager) ListRoutines() []string
ListRoutines returns a slice of names of all routines managed by routine manager.
func (*RoutineManager) RestartRoutine ¶
func (m *RoutineManager) RestartRoutine(name string) error
RestartRoutine restarts a routine, stopping it if it's currently running.
func (*RoutineManager) StartRoutine ¶
func (m *RoutineManager) StartRoutine(name string) error
StartRoutine activates a routine, allowing it to run.
func (*RoutineManager) StopRoutine ¶
func (m *RoutineManager) StopRoutine(name string) error
StopRoutine deactivates a routine, preventing it from running.
func (*RoutineManager) Terminate ¶
func (m *RoutineManager) Terminate() error
Terminate stops all activated routines and waits for them to finish.
type TaskletHandler ¶
type TaskletHandler struct { // Log is the logger instance for application logging. Log *logging.Logger // contains filtered or unexported fields }
TaskletHandler manages a Tasklet's lifecycle.
func NewTaskletHandler ¶
func NewTaskletHandler(log *logging.Logger, tsk Tasklet) *TaskletHandler
NewTaskletHandler creates a new tasklet handler.
func (*TaskletHandler) Disable ¶
func (h *TaskletHandler) Disable()
Disable sets the tasklet as disabled
func (*TaskletHandler) Enable ¶
func (h *TaskletHandler) Enable()
Enable sets the tasklet as enabled
func (*TaskletHandler) IsAlive ¶
func (h *TaskletHandler) IsAlive() bool
IsAlive returns whether the tasklet is currently active and running.
func (*TaskletHandler) IsEnabled ¶
func (h *TaskletHandler) IsEnabled() bool
IsEnabled returns whether the tasklet is currently enabled.
func (*TaskletHandler) IsInitialized ¶
func (h *TaskletHandler) IsInitialized() bool
IsInitialized returns whether the tasklet is currently initialized.
func (*TaskletHandler) Kill ¶
func (h *TaskletHandler) Kill()
Kill terminates the tasklet by setting both kill and termination events.
func (*TaskletHandler) Run ¶
func (h *TaskletHandler) Run()
Run initiates the tasklet lifecycle, handling initialization, execution, and termination.
func (*TaskletHandler) Sleep ¶
func (h *TaskletHandler) Sleep(timeout float64) bool
Sleep pauses execution for the given timeout duration (in seconds), and waits for either a termination or kill event.
func (*TaskletHandler) Start ¶
func (h *TaskletHandler) Start()
Start initiates the tasklet lifecycle, handling initialization, execution, and termination.
func (*TaskletHandler) Stop ¶
func (h *TaskletHandler) Stop()
Stop gracefully stops the tasklet by setting the termination event.
func (*TaskletHandler) WaitStop ¶
func (h *TaskletHandler) WaitStop(timeout float64) bool
WaitStop waits for tasklet to stop for the given timeout duration (in seconds), returns true if tasklet is stopped before timeout is reached.