modulesdk

package
v0.0.0-...-cd6442e Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 10 Imported by: 1 module, 17 packages

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 modulesdk runs a package host for the kernel: it builds the package, hands it to the kernel, which calls it directly, and reaches the kernel over the package bridge. The kernel runs every host inside its own process and hands it its settings and bridge (WithInProcess).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, options Options) error

Run serves the host the kernel started with ctx (WithInProcess) until ctx ends.

func WithInProcess

func WithInProcess(ctx context.Context, host InProcess) context.Context

WithInProcess carries the kernel's InProcess to Run.

Types

type Bridge

Bridge is the package bridge a host package uses.

type Host

type Host struct {
	PackageID string
	Bridge    Bridge
	// LeaseID identifies this host instance in Health answers.
	LeaseID string
	Logf    func(string, ...any)
	// Getenv reads the settings the kernel gave the host. It never reads
	// Control's environment.
	Getenv func(string) string
}

Host is what a package receives to build itself.

type InProcess

type InProcess struct {
	Getenv func(string) string
	Bridge grpc.ClientConnInterface
	// Logf, when set, replaces the host's default logger (log.Printf), so
	// its lines name the package in Control's log.
	Logf func(string, ...any)
	// Ready receives the built package; the kernel calls it from then on.
	Ready func(pluginhostsdk.Package)
}

InProcess is what the kernel hands a host it runs inside its own process: the host's settings, its end of the package bridge, and where to hand the built package.

type Options

type Options struct {
	PackageID      string
	PackageVersion string
	// Build returns the package the host serves. A package that implements
	// Run(context.Context) is run for the life of the host, one that
	// implements pluginhostsdk.ResumablePackage is resumed after a drain,
	// and one that implements ServiceRegistrant serves its extra gRPC
	// services to the kernel (in process, with no transport).
	Build func(Host) (pluginhostsdk.Package, error)
	Logf  func(string, ...any)
}

Options configures Run.

type ServiceRegistrant

type ServiceRegistrant interface {
	RegisterServices(grpc.ServiceRegistrar)
}

ServiceRegistrant is a package that serves gRPC services of its own, such as a contract the kernel calls.

Jump to

Keyboard shortcuts

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