background

package
v0.1.0-rc.50 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: BSD-3-Clause Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package background owns the native child process and local control socket for an ordinary background job. commands supply startup facts and presentation.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("background job not found")

ErrNotFound means there is no reachable socket owner for the exact ID in this state directory. it is not confirmation that a stop request was processed.

Functions

func Launch

func Launch(ctx context.Context, opts LaunchOptions, receipt func(context.Context, Entry) error) (result error)

Launch starts one child in its own session. the receipt callback is synchronous and shares the handoff deadline; use ReceiptWriter for its output. a failed receipt or canceled startup stops and reaps the child.

func Ready

func Ready(ctx context.Context, ready Readiness) error

Ready reports readiness from the serving operation. the first observation sends the startup receipt; later observations update only the job's live state. it is a no-op in an ordinary foreground operation.

func ReceiptWriter

func ReceiptWriter(ctx context.Context, output io.Writer) io.Writer

ReceiptWriter bounds backpressure on pipes and terminal streams during handoff. other writers are called directly and must not block beyond the context.

func Reconnecting

func Reconnecting(ctx context.Context)

Reconnecting marks lost readiness without starting a new job or sending a second receipt. before the first ready observation the job is still starting.

func RunChild

func RunChild(ctx context.Context, run func(context.Context, Bootstrap) error) (result error)

RunChild serves one private bootstrap invocation. run must join its work before returning, whether it stops by request or process cancellation.

Types

type Bootstrap

type Bootstrap struct {
	JobID    string          `json:"job_id"`
	StateDir string          `json:"state_dir"`
	Kind     Kind            `json:"kind"`
	Payload  json.RawMessage `json:"payload,omitempty"`
}

Bootstrap carries the canonical state root and the operation's validated startup payload on an inherited, private channel, never in the child's argv.

type Entry

type Entry struct {
	JobID    string `json:"job_id"`
	StateDir string `json:"-"`
	Kind     Kind   `json:"kind"`
	State    State  `json:"state"`
	PID      int    `json:"pid"`
	Readiness
}

func List

func List(ctx context.Context, stateDir string) ([]Entry, error)

func Status

func Status(ctx context.Context, stateDir, id string) (Entry, error)

func Stop

func Stop(ctx context.Context, stateDir, id string) (Entry, error)

Stop asks the exact socket owner to cancel its work. if the operation joins promptly it also confirms StateStopped on that connection; otherwise the acknowledgement reports StateStopping. a lost socket proves neither.

type Kind

type Kind string
const (
	KindPublish   Kind = "publish"
	KindConnect   Kind = "connect"
	KindPublisher Kind = "publisher"
)

type LaunchOptions

type LaunchOptions struct {
	StateDir string
	Binary   string
	Args     []string // fixed private entry point, not the public command argv
	Kind     Kind
	Payload  json.RawMessage
}

type Readiness

type Readiness struct {
	Address        string          `json:"address,omitempty"`
	Target         string          `json:"target,omitempty"`
	TunnelID       string          `json:"tunnel_id,omitempty"`
	ServiceID      string          `json:"service_id,omitempty"`
	ConnectCommand []string        `json:"connect_command,omitempty"`
	Profile        json.RawMessage `json:"profile,omitempty"`
	GuestEntryURL  string          `json:"guest_entry_url,omitempty"`
}

Readiness is reported by the serving operation, not inferred by the launcher. Profile carries the connector's own shape. Profile, ConnectCommand, and GuestEntryURL go only to the launcher, not status and list.

type ReceiptWriteError

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

ReceiptWriteError marks a failed descriptor write. callers must not retry it through an unbounded diagnostic writer, which may share the failed descriptor.

func (*ReceiptWriteError) Error

func (e *ReceiptWriteError) Error() string

func (*ReceiptWriteError) Unwrap

func (e *ReceiptWriteError) Unwrap() error

type State

type State string
const (
	StateStarting     State = "starting"
	StateReady        State = "ready"
	StateReconnecting State = "reconnecting"
	StateStopping     State = "stopping"
	StateStopped      State = "stopped"
)

Jump to

Keyboard shortcuts

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