runconfig

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 12 Imported by: ? 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 runconfig owns goav runtime construction options.

The root goav package stays focused on recipe grammar. Import this package when an application needs to configure a bare runtime, register custom codecs, formats, filters, or URL schemes, change buffering, or inject clocks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(config *Config) error

Validate reports invalid runtime construction state.

Types

type Config

type Config struct {
	Codecs           *codec.Registry
	Filters          *filter.Registry
	Formats          *format.Registry
	Buffer           pipeline.BufferPolicy
	Realtime         bool
	Clock            av.Clock
	EventCapacity    int
	CloseWaitTimeout time.Duration
	MediaPools       bool
	ShapeDeltas      []ShapeDeltaContributor
	QoSPolicy        func(av.Event) []control.Control
	// Schemes maps lower-case URL schemes to the providers goav.FromURI
	// and goav.ToURI resolve through (see WithScheme and provider.Scheme).
	Schemes map[string]provider.Scheme
}

Config is the mutable runtime construction state passed to Option values. Options may replace registries or update graph policy, but NewConfig validates the final config before the root package publishes a concrete Runtime.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a new bare runtime configuration: per-runtime registries with no adapters beyond content sniffing. Realtime is off, so a job paces only when one of its inputs is live (see WithRealtime).

func NewConfig

func NewConfig(options ...Option) (*Config, error)

NewConfig builds the default bare runtime configuration, applies options in order, and validates the result.

type Option

type Option func(*Config) error

Option configures a runtime under construction: registries (codecs, formats, filters), pacing (WithRealtime, WithClock), graph policy (WithBufferPolicy, WithEventCapacity, WithCloseWaitTimeout), and optional runtime-owned scratch pooling. Invalid options return an error from goav.New instead of silently no-oping.

func WithBufferPolicy

func WithBufferPolicy(policy pipeline.BufferPolicy) Option

WithBufferPolicy sets the default node buffer policy for graphs this runtime builds. Branch-local .Buffer(flow....) declarations override it per branch.

func WithClock

func WithClock(clock av.Clock) Option

WithClock sets the time source the runtime's realtime pacing uses. Nil or unset defaults to av.MonotonicClock().

func WithCloseWaitTimeout

func WithCloseWaitTimeout(timeout time.Duration) Option

WithCloseWaitTimeout sets the diagnostic timeout graph Close and Remove use while waiting for in-flight handlers to drain. A zero timeout keeps the pipeline default.

func WithCodecAdapter

func WithCodecAdapter(register func(*codec.Registry)) Option

WithCodecAdapter registers a whole codec bundle at once: the callback receives the runtime's codec registry. Use WithDecoder/WithEncoder for the direct single-value form.

func WithCodecDescriptor

func WithCodecDescriptor(desc codec.Descriptor) Option

WithCodecDescriptor registers a codec descriptor without an implementation, so capability checks (Explain, validation) recognize the codec even when encode/decode factories come from elsewhere.

func WithCodecPreference

func WithCodecPreference(id av.CodecID, mode codec.Mode, order ...string) Option

WithCodecPreference sets the order the runtime picks the backends of codec id in mode (decode or encode) in when a recipe names none (codec.Backend names one): backend names or kinds (codec.KindHardware, KindLib, KindGo), most preferred first. An empty id or mode applies to every codec or mode. Backends it leaves out follow the default order: hardware, then shared libraries, then pure Go. Only backends whose declared capabilities and knobs fit a request are candidates; one that fails to open is an error, never a reason to try the next.

func WithDecoder

func WithDecoder(desc codec.Descriptor, factory codec.DecoderFactory) Option

WithDecoder adds one decoder factory by descriptor.

func WithDemuxer

func WithDemuxer(id av.FormatID, factory format.DemuxerFactory) Option

WithDemuxer adds one demuxer factory for a container format.

func WithEncoder

func WithEncoder(desc codec.Descriptor, factory codec.EncoderFactory) Option

WithEncoder adds one encoder factory by descriptor.

func WithEventCapacity

func WithEventCapacity(capacity int) Option

WithEventCapacity sets the buffered capacity of the task event stream and of each Watch subscriber's channel (default 256). Events never block the data plane: a full buffer sheds the event and counts the drop.

func WithFilter

func WithFilter(desc filter.Descriptor, factory filter.Factory) Option

WithFilter adds one filter factory by descriptor.

func WithFilterAdapter

func WithFilterAdapter(register func(*filter.Registry)) Option

WithFilterAdapter registers a whole filter bundle at once: the callback receives the runtime's filter registry.

func WithFormatAdapter

func WithFormatAdapter(register func(*format.Registry)) Option

WithFormatAdapter registers a whole container-format bundle at once: the callback receives the runtime's format registry.

func WithMediaPools

func WithMediaPools(enabled bool) Option

WithMediaPools enables runtime-scoped scratch pools for cold attach/detach churn. Pools are owned by one Runtime, never shared globally, and only recycle internal media scratch whose lifetime the runtime controls.

func WithMuxer

func WithMuxer(id av.FormatID, factory format.MuxerFactory) Option

WithMuxer adds one muxer factory for a container format.

func WithProber

func WithProber(prober format.Prober) Option

WithProber adds one format prober for content sniffing.

func WithQoSPolicy

func WithQoSPolicy(policy func(av.Event) []control.Control) Option

WithQoSPolicy sets the opt-in, per-runtime QoS policy: every task this runtime builds feeds each av.EventQoS report (read it with av.EventQoSReport) to the policy on the task's cold event-delivery path and issues the returned controls through the task's own Control seam — exactly what an application could do by hand with Watch + Control, packaged. A control the task refuses is published back through Watch as an av.EventQoS carrying the error on Cause. Reports describe delivery lateness at the task's gates and queues, not network conditions; transports keep their own congestion control.

func WithRealtime

func WithRealtime(realtime bool) Option

WithRealtime controls whether every job on the runtime runs in realtime mode. When true, file media is paced to the runtime clock, graphs buffer between stages, and encoders use low-latency presets. When false (the default), realtime follows the inputs: live sources run realtime and file-to-file work runs as fast as the machine allows.

func WithScheme

func WithScheme(name string, scheme provider.Scheme) Option

WithScheme registers the provider goav.FromURI and goav.ToURI resolve URLs of one scheme through (a provider.InputScheme, a provider.DestinationScheme, or both), per runtime: runconfig.WithScheme("whep", webrtcav.WHEP()). Names are case-insensitive RFC 3986 schemes, and the last registration of a name wins, so a runtime can replace a bundled scheme (an https client with its own transport, say). bundle.Schemes registers file, http, and https.

func WithShapeDelta

func WithShapeDelta(contributor ShapeDeltaContributor) Option

WithShapeDelta registers one per-runtime shape-solver extension. The contributor is consulted only when .Auto(...) is active; use shape.AllowCustom("name") in the policy returned by the contributor and in caller recipes to make a custom class explicit.

type ShapeDeltaContributor

type ShapeDeltaContributor interface {
	ShapeDelta(ShapeDeltaRequest) (ShapeDeltaPlan, bool, error)
}

ShapeDeltaContributor teaches one runtime how to plan a custom .Auto(...) conversion class. Return planned=false when this contributor does not apply to the request.

type ShapeDeltaFunc

type ShapeDeltaFunc func(ShapeDeltaRequest) (ShapeDeltaPlan, bool, error)

ShapeDeltaFunc adapts a function into a ShapeDeltaContributor.

func (ShapeDeltaFunc) ShapeDelta

func (f ShapeDeltaFunc) ShapeDelta(request ShapeDeltaRequest) (ShapeDeltaPlan, bool, error)

ShapeDelta calls f(request).

type ShapeDeltaPlan

type ShapeDeltaPlan struct {
	Component string
	Detail    string
	Needed    shape.Policy
	Stage     pipeline.Stage
}

ShapeDeltaPlan is one custom solver insertion. Stage must be a fresh pipeline.Stage for this planning call; stages that implement shape.Contract teach the planner the output shape after insertion.

type ShapeDeltaRequest

type ShapeDeltaRequest struct {
	Actual     shape.Spec
	Expected   shape.Spec
	Preference shape.Spec
	Realtime   bool
}

ShapeDeltaRequest is passed to a runtime-registered shape solver extension when a chain's .Auto(...) policy is active and the next operation needs a shape the current stream does not satisfy.

Jump to

Keyboard shortcuts

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