shared

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateFile  = "factory_state.json"
	TargetGoal = 100
)

Variables

This section is empty.

Functions

func RunFactory

func RunFactory(sup lifecycle.Supervisor, store *Store, suspendHandler *lifecycle.SuspendHandler)

RunFactory executes the standard interactive factory logic for suspend examples.

Types

type Blocker

type Blocker struct {
	*lifecycle.BaseWorker
}

Blocker is a worker that refuses to suspend quickly, testing the USER's patience.

func NewBlocker

func NewBlocker() *Blocker

func (*Blocker) Resume

func (b *Blocker) Resume(ctx context.Context) error

func (*Blocker) Start

func (b *Blocker) Start(ctx context.Context) error

func (*Blocker) Suspend

func (b *Blocker) Suspend(ctx context.Context) error

type FactoryState

type FactoryState struct {
	ItemsProduced  int `json:"items_produced"`
	ItemsProcessed int `json:"items_processed"`
}

FactoryState represents the persisted state of our factory.

type Store

type Store struct {
	Mu    sync.Mutex
	State FactoryState
	Path  string
}

Store manages persistence of factory state.

func NewStore

func NewStore(path string) *Store

func (*Store) Cleanup

func (s *Store) Cleanup()

Cleanup removes the state file and resets internal counters.

func (*Store) Load

func (s *Store) Load()

Load reads state from disk if it exists.

func (*Store) Save

func (s *Store) Save(ctx context.Context) error

Save persists the current state to disk.

type Watchdog

type Watchdog struct {
	*lifecycle.BaseWorker
}

Watchdog is a system service that runs continuously, ignoring suspension.

func NewWatchdog

func NewWatchdog() *Watchdog

func (*Watchdog) Run

func (w *Watchdog) Run(ctx context.Context) error

func (*Watchdog) Start

func (w *Watchdog) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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