loop

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package loop provides a recurring-prompt scheduler for the piglet loop extension. It is free of SDK dependencies and fully testable in isolation.

Index

Constants

This section is empty.

Variables

View Source
var MinInterval = 30 * time.Second

MinInterval is the minimum allowed scheduling interval. Tests may lower this to speed up timing assertions.

Functions

func Register

func Register(e *sdk.Extension)

Register adds loop's prompt section and commands to the extension.

Types

type Scheduler

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

Scheduler runs a prompt on a recurring interval. All methods are safe for concurrent use.

func (*Scheduler) Start

func (s *Scheduler) Start(interval time.Duration, prompt string, onTick func(iteration int, prompt string)) error

Start launches the scheduler. It calls onTick immediately (iteration 1), then again after each interval. Returns an error if:

  • interval < MinInterval
  • the scheduler is already running

func (*Scheduler) Status

func (s *Scheduler) Status() (running bool, interval time.Duration, prompt string, iterations int)

Status returns the current scheduler state.

func (*Scheduler) Stop

func (s *Scheduler) Stop() bool

Stop cancels the active loop and waits for the goroutine to exit. Returns true if a loop was running, false if there was nothing to stop.

Directories

Path Synopsis
Loop extension binary.
Loop extension binary.

Jump to

Keyboard shortcuts

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