bgRoutine

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 8 Imported by: 0

README

bgRoutine (Background Routine)

This package will take care of the functionality involved and concerning background routines. This can be used for (but it not limited to) creating job systems. However, it does not try to replace an existing full blown Job system.

The routine manager is supposed to let you Start, Pause, Resume and Stop a routine. You can schedule a routine either with a Cron Job expression or as a function that runs every x intervals (e.g. every 20 seconds). You can configure a routine to have a single instance or multiple instances.

Documentation

Index

Constants

View Source
const (
	StateUninitialized = "uninitialized"
	StateInitialized   = "initialized"
	StatePaused        = "paused"
	StateRunning       = "running"
	StateTerminated    = "terminated"
)
View Source
const (
	CronMode   = "cronMode"   // When we are working in the cron mode
	TickerMode = "tickerMode" // When we are working in the ticker mode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager added in v0.1.2

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

func NewManager added in v0.1.2

func NewManager() Manager

func (*Manager) AddRoutine added in v0.1.2

func (m *Manager) AddRoutine(name string, cronExpression string, runnerFunc func() appError.Typ) appError.Typ

func (*Manager) ShutdownAllRoutines added in v0.1.2

func (m *Manager) ShutdownAllRoutines()

type Typ

type Typ struct {
	Name string // Name of the routine
	// contains filtered or unexported fields
}

func (*Typ) AddMonitorFunc

func (r *Typ) AddMonitorFunc(f func(typ appError.Typ))

func (*Typ) CurrentMode

func (r *Typ) CurrentMode() string

func (*Typ) GetCurrentState

func (r *Typ) GetCurrentState() string

func (*Typ) IsPaused

func (r *Typ) IsPaused() bool

func (*Typ) IsRunning

func (r *Typ) IsRunning() bool

func (*Typ) IsTerminated

func (r *Typ) IsTerminated() bool

func (*Typ) Pause

func (r *Typ) Pause()

func (*Typ) Resume

func (r *Typ) Resume()

func (*Typ) Start

func (r *Typ) Start(launchRightNow bool) appError.Typ

func (*Typ) Stop

func (r *Typ) Stop()

Jump to

Keyboard shortcuts

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