pluginruntime

package
v0.0.0-...-12a8c20 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveSymbol

func ResolveSymbol[T any](symbol any) (T, bool)

ResolveSymbol accepts either a direct implementation or a pointer to one.

func ValidateRepositoryURL

func ValidateRepositoryURL(raw string) error

ValidateRepositoryURL rejects local filesystem paths and unsupported URL schemes before the runtime invokes git. HTTPS and SSH-style Git URLs are allowed.

Types

type BuildSpec

type BuildSpec[T any] struct {
	LogPrefix      string
	AppDir         string
	CacheDir       string
	TempDir        string
	HostPackageDir string
	ClonePrefix    string
	SymbolName     string
	DefaultGitRef  string
	BuildTimeout   time.Duration
	Resolver       SymbolResolver[T]
}

BuildSpec describes how a runtime extension should be cloned, compiled, cached, and opened inside the host module.

type Loader

type Loader[T any] struct {
	// contains filtered or unexported fields
}

Loader compiles and loads runtime extensions using a shared clone/build/cache/open flow.

func NewLoader

func NewLoader[T any](spec BuildSpec[T]) (*Loader[T], error)

NewLoader validates the build spec and prepares the cache/temp directories.

func (*Loader[T]) CompileAndLoad

func (l *Loader[T]) CompileAndLoad(name, repoURL, gitRef, commitHash string) (T, string, error)

CompileAndLoad clones repoURL, compiles the extension, caches the .so by commit, and loads it. Builds for the same logical plugin are serialized across goroutines and cooperating processes to avoid cache and source directory races.

func (*Loader[T]) LoadCached

func (l *Loader[T]) LoadCached(name string) (T, error)

LoadCached loads a previously compiled extension from the shared cache.

func (*Loader[T]) LoadPath

func (l *Loader[T]) LoadPath(name, artifactPath string) (T, error)

func (*Loader[T]) MetaPath

func (l *Loader[T]) MetaPath(name string) string

MetaPath returns the cache metadata location for the compiled .so.

func (*Loader[T]) SoPath

func (l *Loader[T]) SoPath(name string) string

SoPath returns the cache location for the currently selected compiled .so.

type Registry

type Registry[T any] struct {
	// contains filtered or unexported fields
}

Registry is a threadsafe named registry for runtime extensions.

func NewRegistry

func NewRegistry[T any]() *Registry[T]

NewRegistry creates an empty registry.

func (*Registry[T]) Delete

func (r *Registry[T]) Delete(name string)

Delete removes an item from the registry.

func (*Registry[T]) Get

func (r *Registry[T]) Get(name string) (T, bool)

Get returns the item registered under name.

func (*Registry[T]) Names

func (r *Registry[T]) Names() []string

Names returns a snapshot of all registered names.

func (*Registry[T]) Register

func (r *Registry[T]) Register(name string, item T)

Register stores an item under name.

type SymbolResolver

type SymbolResolver[T any] func(symbol any) (T, bool)

SymbolResolver converts a looked-up plugin symbol into the requested runtime type.

Jump to

Keyboard shortcuts

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