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 ¶
Types ¶
type Bridge ¶
type Bridge interface {
pluginhostsdk.RouterBridge
pluginhostsdk.RouterWebSocketBridge
LeaseStorage(ctx context.Context) (packagebridgesdk.StorageLease, error)
}
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.