contract

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WITPackageNamespace = "examples"
	WITPackageName      = "contract"
	WITPackageVersion   = "1.0.0"
	WITPackageID        = "examples:contract@1.0.0"
)

Variables

View Source
var HostDescriptor = witgo.InterfaceDescriptor{
	ID: "examples:contract/host@1.0.0",
	Functions: map[string]string{
		"process-string": "(string)->(string)",
	},
}
View Source
var PluginInfoDescriptor = witgo.InterfaceDescriptor{
	ID: "examples:contract/plugin-info@1.0.0",
	Functions: map[string]string{
		"metadata": "()->(record{name:string,version:string,author:string,description:string})",
	},
}

Functions

func CheckPlugin

func CheckPlugin(filename string) error

CheckPlugin validates a component and returns ErrContractMismatch when it is incompatible.

func CheckPluginContext

func CheckPluginContext(ctx context.Context, filename string) error

func CheckPluginWithOptions

func CheckPluginWithOptions(filename string, options witgo.RuntimeOptions) error

CheckPluginWithOptions is CheckPlugin with explicit bridge options.

func CheckPluginWithOptionsContext

func CheckPluginWithOptionsContext(ctx context.Context, filename string, options witgo.RuntimeOptions) error

func PluginPing

func PluginPing() witgo.Contract

PluginPing returns the generated host and plugin function manifest.

func RegisterHost

func RegisterHost(host *witgo.Host, name string, provider Host, options ...witgo.RegisterOption) error

func RegisterPluginInfo

func RegisterPluginInfo(host *witgo.Host, name string, provider PluginInfo, options ...witgo.RegisterOption) error

func ValidatePlugin

func ValidatePlugin(filename string) (witgo.ValidationReport, error)

ValidatePlugin inspects a component without instantiating it or running guest code.

func ValidatePluginContext

func ValidatePluginContext(ctx context.Context, filename string) (witgo.ValidationReport, error)

func ValidatePluginWithOptions

func ValidatePluginWithOptions(filename string, options witgo.RuntimeOptions) (witgo.ValidationReport, error)

ValidatePluginWithOptions is ValidatePlugin with explicit bridge options.

func ValidatePluginWithOptionsContext

func ValidatePluginWithOptionsContext(ctx context.Context, filename string, options witgo.RuntimeOptions) (witgo.ValidationReport, error)

Types

type Host

type Host interface {
	ProcessString(ctx context.Context, value string) (string, error)
}

func AutoResolveHost

func AutoResolveHost(host *witgo.Host) (Host, error)

func MustResolveHost

func MustResolveHost(host *witgo.Host, name string) Host

func ResolveHost

func ResolveHost(host *witgo.Host, name string) (Host, error)

type HostProviderClient

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

func (*HostProviderClient) ProcessString

func (c *HostProviderClient) ProcessString(ctx context.Context, value string) (string, error)

type Plugin

type Plugin struct {
	PluginInfo PluginInfo
	// contains filtered or unexported fields
}

Plugin is a client for the plugin WIT world.

func OpenPlugin

func OpenPlugin(filename string, imports ...PluginImports) (*Plugin, error)

OpenPlugin loads a component using the generated contract.

func OpenPluginAutoBoundWithHost

func OpenPluginAutoBoundWithHost(host *witgo.Host, filename string) (*Plugin, error)

func OpenPluginAutoBoundWithHostContext

func OpenPluginAutoBoundWithHostContext(ctx context.Context, host *witgo.Host, filename string) (*Plugin, error)

func OpenPluginContext

func OpenPluginContext(ctx context.Context, filename string, imports ...PluginImports) (*Plugin, error)

OpenPluginContext loads a component and propagates cancellation during startup.

func OpenPluginWithHost

func OpenPluginWithHost(host *witgo.Host, filename string, bindings ...PluginBindings) (*Plugin, error)

OpenPluginWithHost opens a component attached to a shared composition host.

func OpenPluginWithHostContext

func OpenPluginWithHostContext(ctx context.Context, host *witgo.Host, filename string, bindings ...PluginBindings) (*Plugin, error)

func OpenPluginWithHostOptionsContext

func OpenPluginWithHostOptionsContext(ctx context.Context, host *witgo.Host, filename string, options witgo.RuntimeOptions, bindings ...PluginBindings) (*Plugin, error)

func OpenPluginWithOptions

func OpenPluginWithOptions(filename string, _witgoOptions witgo.RuntimeOptions, imports ...PluginImports) (*Plugin, error)

OpenPluginWithOptions loads a component with runtime options and verifies its function manifest.

func OpenPluginWithOptionsContext

func OpenPluginWithOptionsContext(ctx context.Context, filename string, _witgoOptions witgo.RuntimeOptions, _witgoImportSets ...PluginImports) (*Plugin, error)

OpenPluginWithOptionsContext loads a component with context and runtime options.

func OpenPluginWithPolicy added in v1.1.0

func OpenPluginWithPolicy(policy witgo.HostPolicy, pluginID, filename string, imports ...PluginImports) (*Plugin, error)

OpenPluginWithPolicy resolves permissions and limits owned by the host.

func OpenPluginWithPolicyContext added in v1.1.0

func OpenPluginWithPolicyContext(ctx context.Context, policy witgo.HostPolicy, pluginID, filename string, imports ...PluginImports) (*Plugin, error)

func (*Plugin) Close

func (c *Plugin) Close() error

func (*Plugin) Restart

func (c *Plugin) Restart() error

func (*Plugin) RestartContext

func (c *Plugin) RestartContext(ctx context.Context) error

type PluginBindings

type PluginBindings = PluginImports

PluginBindings is the typed dependency set used for Go and plugin providers.

func AutoBindPlugin

func AutoBindPlugin(host *witgo.Host) (PluginBindings, error)

AutoBindPlugin resolves every dependency when exactly one compatible provider is registered.

type PluginImports

type PluginImports struct {
	Host Host
}

PluginImports contains all host capabilities required by Plugin.

type PluginInfo

type PluginInfo interface {
	Metadata(ctx context.Context) (PluginMetadata, error)
}

func AutoResolvePluginInfo

func AutoResolvePluginInfo(host *witgo.Host) (PluginInfo, error)

func MustResolvePluginInfo

func MustResolvePluginInfo(host *witgo.Host, name string) PluginInfo

func ResolvePluginInfo

func ResolvePluginInfo(host *witgo.Host, name string) (PluginInfo, error)

type PluginInfoProviderClient

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

func (*PluginInfoProviderClient) Metadata

type PluginMetadata

type PluginMetadata struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Author      string `json:"author"`
	Description string `json:"description"`
}

Jump to

Keyboard shortcuts

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