autonomy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package autonomy is the in-process foundation for proactive (cron-like) agent behavior. It runs registered jobs on a fixed interval. It is gated OFF by default at the config layer (host-configured; off unless the embedder enables it); the ecosystem direction is to queue/receive proactive work as Aether tasks, with this in-process layer as a bridge/fallback. See docs/cron-proactive-autonomy.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	Name() string
	Run(ctx context.Context) error
}

Job is a unit of proactive work run on the scheduler's interval.

type JobFunc

type JobFunc struct {
	JobName string
	Fn      func(ctx context.Context) error
}

JobFunc adapts a function to Job.

func (JobFunc) Name

func (j JobFunc) Name() string

func (JobFunc) Run

func (j JobFunc) Run(ctx context.Context) error

type Scheduler

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

Scheduler runs its registered jobs every interval until stopped. A non-positive interval or an empty job set makes Start a no-op, so the disabled-by-default path costs nothing.

func NewScheduler

func NewScheduler(interval time.Duration) *Scheduler

NewScheduler returns a scheduler that fires every interval.

func (*Scheduler) Register

func (s *Scheduler) Register(job Job)

Register adds a job. Call before Start.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) bool

Start launches the loop in a goroutine until ctx is cancelled or Stop is called. It is a no-op (and reports false) when disabled (interval <= 0 or no jobs), so callers can branch on activation.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop cancels the loop and waits for it to drain. Safe to call when Start was a no-op or already stopped.

Jump to

Keyboard shortcuts

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