Documentation
¶
Overview ¶
Package sdk composes plugin capabilities, connection-context transport, and process serving.
Index ¶
- Constants
- Variables
- func ClientPluginContextInterceptor(log logging.Logger) grpc.UnaryClientInterceptor
- func GRPCDialOptions() []grpc.DialOption
- func GRPCDialOptionsWithLogger(log logging.Logger) []grpc.DialOption
- func GRPCServerFactory(opts []grpc.ServerOption) *grpc.Server
- func GRPCServerFactoryWithLogger(log logging.Logger, opts []grpc.ServerOption) *grpc.Server
- func LegacyClientPluginContextInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, ...) errordeprecated
- func RegisterResourcePlugin(p *Plugin, provider resourcev2.Provider)
- func StreamClientPluginContextInterceptor(log logging.Logger) grpc.StreamClientInterceptor
- func UseClientPluginContext(ctx context.Context) (context.Context, error)
- type Plugin
- func (p *Plugin) Activities() activity.Reporter
- func (p *Plugin) GetMeta() config.PluginMeta
- func (p *Plugin) GetPluginID() string
- func (p *Plugin) GetPluginMap() map[string]plugin.Plugin
- func (p *Plugin) RegisterCapability(capability string, registration plugin.Plugin)
- func (p *Plugin) Serve()
- func (p *Plugin) SetLogLevel(level logging.Level)
- type PluginOpts
Constants ¶
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.
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.
const LogLevelEnvironment = "OMNIVIEW_PLUGIN_LOG_LEVEL"
LogLevelEnvironment names the environment variable the host uses to set the initial plugin log level (trace, debug, info, warn, error). It is ignored when PluginOpts.Debug is set.
Variables ¶
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
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.
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) Activities ¶ added in v0.15.0
Activities returns the process-scoped reporter. Calls fail until the host binds the callback service; reporting never grants access to delegated connections.
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 ¶
GetPluginID returns the ID loaded from the installed plugin manifest.
func (*Plugin) GetPluginMap ¶
GetPluginMap returns the plugin map for the plugin based on the capabilities that have been registered.
func (*Plugin) RegisterCapability ¶
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
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.