plugin

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package plugin provides the core Plugin interface and WASM export lifecycle.

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.1.0"

Version is the SDK version, set at build time.

Functions

func CallHost

func CallHost[Req any, Resp any](hostFunc func(uint64) uint64, req Req) (Resp, error)

CallHost invokes a host function that uses the SDK's packed uint64 ABI.

func MustRegisterService added in v0.3.0

func MustRegisterService(plugin *PluginDefinition, svc interface{})

MustRegisterService registers a service or panics. Use this in init() functions.

func PackBytes

func PackBytes(data []byte) uint64

PackBytes packs a byte slice into a uint64 (ptr << 32 | len).

func Register

func Register(p Plugin)

Register is a stub for non-WASM platforms.

func RegisterService added in v0.3.0

func RegisterService(plugin *PluginDefinition, svc interface{}) error

RegisterService registers all operations from a service struct.

func UnpackBytes

func UnpackBytes(packed uint64) []byte

UnpackBytes unpacks a uint64 into a byte slice.

Types

type HandlerFunc added in v0.3.0

type HandlerFunc func(ctx context.Context, req *Request) (*entities.Result, error)

HandlerFunc is the signature for operation handlers.

type Op added in v0.3.0

type Op struct{}

Op is a field type for declaring operations. Tag format: `desc:"Operation description"`

type Plugin

type Plugin interface {
	Manifest(ctx context.Context) (*entities.Manifest, error)
	Check(ctx context.Context, config []byte) (*entities.Result, error)
}

Plugin is the interface every Reglet plugin must implement.

type PluginDef added in v0.3.0

type PluginDef struct {
	Name         string
	Version      string
	Description  string
	Config       interface{} // Struct for schema generation
	Capabilities []entities.Capability
}

PluginDef defines plugin identity and configuration.

type PluginDefinition added in v0.3.0

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

PluginDefinition holds the parsed plugin definition and registered services.

func DefinePlugin added in v0.3.0

func DefinePlugin(def PluginDef) *PluginDefinition

DefinePlugin creates a new plugin definition. Call this once at package level in your plugin.

func (*PluginDefinition) GetHandler added in v0.3.0

func (p *PluginDefinition) GetHandler(serviceName, opName string) (HandlerFunc, bool)

GetHandler returns a handler for the given service/operation.

func (*PluginDefinition) Manifest added in v0.3.0

func (p *PluginDefinition) Manifest() *entities.Manifest

Manifest returns the complete plugin manifest.

func (*PluginDefinition) RegisterHandler added in v0.3.0

func (p *PluginDefinition) RegisterHandler(serviceName, serviceDesc, opName, opDesc string, handler HandlerFunc)

RegisterHandler registers a handler for a service/operation. Called internally by RegisterService.

type Request added in v0.3.0

type Request struct {
	Client interface{} // Plugin-specific client (e.g., *AWSClient)
	Config interface{} // Parsed config struct
	Raw    []byte      // Raw config JSON
}

Request contains the context for a handler invocation.

type Service added in v0.3.0

type Service struct{}

Service is embedded in service structs to provide metadata. Tag format: `name:"service_name" desc:"Service description"`

type StubPlugin added in v0.3.0

type StubPlugin struct{}

StubPlugin is a no-op implementation of the Plugin interface for testing or non-WASM environments.

func (*StubPlugin) Check added in v0.3.0

func (s *StubPlugin) Check(ctx context.Context, config []byte) (*entities.Result, error)

Check performs a no-op check for the StubPlugin.

func (*StubPlugin) Manifest added in v0.3.0

func (s *StubPlugin) Manifest(ctx context.Context) (*entities.Manifest, error)

Manifest returns a default manifest for the StubPlugin.

Jump to

Keyboard shortcuts

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