lifecycle

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager tracks activity and controls brain lifecycle states

func NewManager

func NewManager() *Manager

NewManager creates a new lifecycle manager

func (*Manager) CheckAndTransition

func (m *Manager) CheckAndTransition(indexID core.IndexID) bool

CheckAndTransition evaluates an index state and transitions if needed Returns true if a transition occurred

func (*Manager) ForceSleep

func (m *Manager) ForceSleep(indexID core.IndexID)

ForceSleep forces an index into sleep state

func (*Manager) ForceWake

func (m *Manager) ForceWake(indexID core.IndexID)

ForceWake forces an index to wake up

func (*Manager) GetActiveUsers

func (m *Manager) GetActiveUsers() []core.IndexID

GetActiveUsers returns all indexes in Active or Idle state

func (*Manager) GetBrainState

func (m *Manager) GetBrainState(indexID core.IndexID) *core.BrainState

GetBrainState returns the full brain state

func (*Manager) GetSleepingUsers

func (m *Manager) GetSleepingUsers() []core.IndexID

GetSleepingUsers returns all indexes in Sleeping state

func (*Manager) GetState

func (m *Manager) GetState(indexID core.IndexID) core.ActivityState

GetState returns the current state for an index

func (*Manager) IsActivitySparse

func (m *Manager) IsActivitySparse(indexID core.IndexID) bool

IsActivitySparse checks if activity has become sparse (trigger for sleep)

func (*Manager) RecordActivity

func (m *Manager) RecordActivity(indexID core.IndexID)

RecordActivity records an index activity event

func (*Manager) RemoveIndex

func (m *Manager) RemoveIndex(indexID core.IndexID)

RemoveIndex drops lifecycle state for an index.

func (*Manager) SetCallbacks

func (m *Manager) SetCallbacks(
	onSleepStart func(core.IndexID),
	onSleepEnd func(core.IndexID),
	onDormant func(core.IndexID),
	onWake func(core.IndexID),
)

SetCallbacks configures lifecycle transition callbacks

func (*Manager) SetThresholds

func (m *Manager) SetThresholds(idle, sleep, dormant time.Duration)

SetThresholds applies lifecycle thresholds at runtime.

func (*Manager) StartMonitor

func (m *Manager) StartMonitor(checkInterval time.Duration)

StartMonitor starts the background lifecycle monitoring

func (*Manager) Stats

func (m *Manager) Stats() map[string]any

Stats returns manager statistics

func (*Manager) Stop

func (m *Manager) Stop()

Stop stops the lifecycle manager

func (*Manager) Thresholds

func (m *Manager) Thresholds() (time.Duration, time.Duration, time.Duration)

Thresholds returns currently active lifecycle thresholds.

Jump to

Keyboard shortcuts

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