routine

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckProcess

func CheckProcess(targetName string) bool

CheckProcess scans the current process tree for a matching name

Types

type Action

type Action struct {
	Type   string      `yaml:"type" json:"type"`
	Target string      `yaml:"target,omitempty" json:"target,omitempty"`
	Value  interface{} `yaml:"value,omitempty" json:"value,omitempty"`
}

type ExemptionHandler

type ExemptionHandler struct {
	// Store the previous state: map[appName]wasExempt
	PreviousStates map[string]bool
}

func (*ExemptionHandler) Apply

func (h *ExemptionHandler) Apply(mm *memory.Manager, apps []interface{})

func (*ExemptionHandler) Cleanup

func (h *ExemptionHandler) Cleanup(mm *memory.Manager)

type Manager

type Manager struct {
	Routines      []*Routine
	Ticker        *time.Ticker
	MemoryManager *memory.Manager
	CapHandler    *MemoryCapHandler // State restorer
}

func NewManager

func NewManager(mm *memory.Manager) *Manager

func (*Manager) Activate

func (m *Manager) Activate(r *Routine)

func (*Manager) Deactivate

func (m *Manager) Deactivate(r *Routine)

func (*Manager) Run

func (m *Manager) Run()

type MemoryCapHandler

type MemoryCapHandler struct {
	OriginalCap  float64
	IsOverridden bool
}

MemoryCapHandler manages the transition between global and routine-specific caps.

func (*MemoryCapHandler) ApplyCap

func (h *MemoryCapHandler) ApplyCap(mm *memory.Manager, newValue interface{}) error

ApplyCap takes the value from the YAML (percentage) and updates the enforcer.

func (*MemoryCapHandler) Restore

func (h *MemoryCapHandler) Restore(mm *memory.Manager)

Restore restores the preset cap and unlocks routine override

type Routine

type Routine struct {
	Name          string        `yaml:"name" json:"name"`
	Enabled       bool          `yaml:"enabled" json:"enabled"`
	Path          string        `yaml:"-" json:"-"`
	Trigger       Trigger       `yaml:"trigger" json:"trigger"`
	Actions       []Action      `yaml:"actions" json:"actions"`
	StopCondition StopCondition `yaml:"stop_condition" json:"stop_condition"`
	IsActive      bool          `yaml:"-" json:"isActive"` // camelCase for JS
}

func LoadRoutine

func LoadRoutine(path string) (*Routine, error)

LoadRoutine reads a YAML file and returns a Routine pointer

type StopCondition

type StopCondition struct {
	Type   string `yaml:"type" json:"type"`
	Target string `yaml:"target" json:"target"`
}

type Trigger

type Trigger struct {
	Type   string `yaml:"type" json:"type"`
	Target string `yaml:"target" json:"target"`
}

Jump to

Keyboard shortcuts

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