local

package
v0.10.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package local executes non-serializable process-local closures as managed tasks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Manager              *backgroundtask.Manager
	Executors            *backgroundtask.ExecutorRegistry
	ForegroundTimeoutMs  *int
	ShouldAutoBackground func(context.Context, *foreground.CandidateInfo) bool
	BackgroundNotice     func(context.Context, NoticeInfo) string
}

Config configures process-local execution and ephemeral foreground projection. Policy callbacks may run concurrently and must not panic or mutate the supplied candidate. Nil ShouldAutoBackground disables automatic detachment; nil BackgroundNotice uses the default notice.

type Input

type Input struct {
	Description                string
	Kind                       string
	Payload                    []byte
	OutputFile                 string
	SessionID                  string
	NotifySession              bool
	RunInBackground            bool
	BackgroundStartupPreviewMs int
	ForegroundTimeoutMs        *int
}

Input describes one process-local execution. ForegroundTimeoutMs overrides Config.ForegroundTimeoutMs. RunInBackground bypasses foreground timeout; BackgroundStartupPreviewMs applies only to its streaming startup preview.

type NoticeInfo

type NoticeInfo struct {
	Task             *backgroundtask.Task
	AutoBackgrounded bool
}

NoticeInfo carries lifecycle facts for a background stream notice. Task may be nil when authoritative loading fails.

type Runner

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

Runner owns one process-local closure registry for a Manager.

func New

func New(config *Config) (*Runner, error)

New constructs a Runner and registers its process-local executor.

func (*Runner) Manager

func (r *Runner) Manager() *backgroundtask.Manager

Manager returns the shared lifecycle Manager.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, input *Input, work WorkFunc) (*backgroundtask.Task, error)

Run executes buffered process-local work.

func (*Runner) RunStream

func (r *Runner) RunStream(
	ctx context.Context,
	input *Input,
	work StreamWorkFunc,
) (*schema.StreamReader[string], error)

RunStream executes streaming process-local work and returns its ephemeral caller-facing projection. Foreground chunks are not task events because no durable task exists until explicit background launch or successful handoff. Closing a foreground reader requests cancellation of this process-local operation; closing a background preview only closes the caller projection.

type StreamWorkFunc

type StreamWorkFunc func(
	ctx context.Context,
	runtime backgroundtask.ExecutionRuntime,
) (*schema.StreamReader[string], error)

StreamWorkFunc performs streaming process-local work.

type WorkFunc

type WorkFunc func(
	ctx context.Context,
	runtime backgroundtask.ExecutionRuntime,
) (string, error)

WorkFunc performs buffered process-local work.

Jump to

Keyboard shortcuts

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