sdk

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 28 Imported by: 2 modules, 1 package

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 sdk composes plugin capabilities, connection-context transport, and process serving.

Index

Constants

View Source
const (
	MDKeyRequestID       = "omniview-request-id"
	MDKeyRequesterID     = "omniview-requester-id"
	MDKeyConnectionID    = "omniview-connection-id"
	MDKeyConnectionData  = "omniview-connection-data"
	MDKeyResourceKey     = "omniview-resource-key"
	MDKeyProtocolVersion = "omniview-protocol-version"
)

Individual metadata keys for the new format.

View Source
const CurrentProtocolVersion = 1

CurrentProtocolVersion is the SDK protocol version that this SDK release implements. It is used as the key in go-plugin's VersionedPlugins map so that the engine and plugin can negotiate the highest common version.

Variables

View Source
var ErrNoPluginContext = errors.New("no plugin context in context")

ErrNoPluginContext is returned when no plugin context is found in the context.

Functions

func ClientPluginContextInterceptor

func ClientPluginContextInterceptor(log logging.Logger) grpc.UnaryClientInterceptor

ClientPluginContextInterceptor propagates request diagnostics and selected connection metadata without granting resource admission. Missing plugin context leaves the call unchanged.

func GRPCDialOptions

func GRPCDialOptions() []grpc.DialOption

GRPCDialOptions returns SDK context propagation and tracing options using the default logger.

func GRPCDialOptionsWithLogger added in v0.2.0

func GRPCDialOptionsWithLogger(log logging.Logger) []grpc.DialOption

GRPCDialOptionsWithLogger returns SDK context propagation and tracing options using log.

func GRPCServerFactory

func GRPCServerFactory(opts []grpc.ServerOption) *grpc.Server

GRPCServerFactory builds a server with SDK middleware and the default logger.

func GRPCServerFactoryWithLogger added in v0.2.0

func GRPCServerFactoryWithLogger(log logging.Logger, opts []grpc.ServerOption) *grpc.Server

GRPCServerFactoryWithLogger builds a server with resource wire limits and SDK middleware.

func LegacyClientPluginContextInterceptor deprecated added in v0.2.0

func LegacyClientPluginContextInterceptor(
	ctx context.Context,
	method string,
	req, reply any,
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

Deprecated: use ClientPluginContextInterceptor(log).

func RegisterResourcePlugin

func RegisterResourcePlugin(p *Plugin, provider resourcev2.Provider)

RegisterResourcePlugin registers the resource-v2 provider. The catalog is required; finite operations are independently optional and catalog-qualified. Resource wire negotiation does not change unrelated utility protocol versions.

func StreamClientPluginContextInterceptor added in v0.9.0

func StreamClientPluginContextInterceptor(log logging.Logger) grpc.StreamClientInterceptor

StreamClientPluginContextInterceptor uses the same admitted utility context transport as unary RPCs. Opening a stream must not drop its selected connection or replace the outgoing catalog/session metadata already present.

func UseClientPluginContext

func UseClientPluginContext(ctx context.Context) (context.Context, error)

UseClientPluginContext serializes the plugin context and injects it into gRPC metadata using individual keys.

Types

type Plugin

type Plugin struct {
	// settingsProvider is the settings provider for the plugin.
	SettingsProvider pkgsettings.Provider

	Log      logging.Logger
	LogLevel *logging.LevelController
	// contains filtered or unexported fields
}

Plugin owns capability registration and process logging. Finish registration before serving; registration and metadata access are not synchronized.

func NewPlugin

func NewPlugin(opts PluginOpts) *Plugin

NewPlugin creates a new plugin with the given configuration. This should be instantiated within your main function for your plugin and passed to the Register* functions to add capabilities to the plugin.

func (*Plugin) GetMeta

func (p *Plugin) GetMeta() config.PluginMeta

GetMeta returns metadata by value; nested containers remain shared and must not be mutated.

func (*Plugin) GetPluginID

func (p *Plugin) GetPluginID() string

GetPluginID returns the ID loaded from the installed plugin manifest.

func (*Plugin) GetPluginMap

func (p *Plugin) GetPluginMap() map[string]plugin.Plugin

GetPluginMap returns the plugin map for the plugin based on the capabilities that have been registered.

func (*Plugin) RegisterCapability

func (p *Plugin) RegisterCapability(capability string, registration plugin.Plugin)

RegisterCapability installs or replaces a transport and binds utility consumers to the resource provider's sole configured connection registry.

func (*Plugin) Serve

func (p *Plugin) Serve()

Serve begins serving the plugin after all capabilities have been registered. It auto-registers lifecycle RPC and leaves handshake transport to go-plugin. The host owns development process supervision; the SDK never advertises or removes legacy .devinfo records. It panics if the effective SDK protocol version exceeds the signed 32-bit lifecycle wire range, rather than advertising a wrapped version. Nonpositive manifest versions continue to use CurrentProtocolVersion.

func (*Plugin) SetLogLevel added in v0.2.0

func (p *Plugin) SetLogLevel(level logging.Level)

SetLogLevel changes both SDK and runtime logging; nil plugins or controllers are ignored.

type PluginOpts

type PluginOpts struct {
	// ID is the unique identifier for the plugin
	ID string

	// Settings is a list of settings to be used by the plugin
	Settings []pkgsettings.Setting

	// Debug is the debug mode for the plugin
	Debug bool
}

PluginOpts is the options for creating a new plugin.

Jump to

Keyboard shortcuts

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