Documentation
¶
Overview ¶
Package framework defines the host/extension contract shared by every extension point in AgentBox (SandboxPool lifecycle Plugins, quota Providers, and future Providers such as billing or telemetry).
It is intentionally small:
- Handle bundles the shared runtime dependencies the host passes to an extension at construction time (controller-runtime client + cache, log).
- Args is the extension-specific parameter object. Each Factory declares the concrete *MyArgs struct it expects and asserts it inside the body; passing nil is legal for extensions that need no parameters.
Concrete Factory signatures live next to each extension point (e.g. pkg/plugins.Factory for SandboxPool plugins, pkg/plugins/quota.Factory for quota Providers) because their return types differ. Registry implementations likewise live in each extension point so they can be strongly typed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Args ¶
type Args any
Args is the extension-specific parameter object passed to a Factory.
Each extension declares a concrete *MyArgs struct and asserts it inside its Factory body:
type MyArgs struct{ URL string }
func Factory(h framework.Handle, args framework.Args) (Plugin, error) {
if args == nil {
return nil, errors.New("myplugin: args required")
}
a, ok := args.(*MyArgs)
if !ok {
return nil, fmt.Errorf("myplugin: got %T, want *MyArgs", args)
}
// use a.URL …
}
Passing nil is legal — use it for extensions that take no parameters.
type DefaultHandle ¶
DefaultHandle is a ready-made Handle implementation used by cmd wiring and tests. Fields are public so callers can build the struct inline; zero values are valid (accessors return the zero value of their declared type).
func (*DefaultHandle) Cache ¶
func (h *DefaultHandle) Cache() cache.Cache
func (*DefaultHandle) Client ¶
func (h *DefaultHandle) Client() client.Client
func (*DefaultHandle) Log ¶
func (h *DefaultHandle) Log() logr.Logger
type Handle ¶
type Handle interface {
// Client returns a controller-runtime client backed by the manager's
// informer cache for reads and the API server for writes.
Client() client.Client
// Cache returns the manager's informer cache. Extensions register their
// own informers here (e.g. a ConfigMap hot-reload watch inside a Plugin's
// Start hook).
Cache() cache.Cache
// Log is the logger extensions should derive children from; the host
// injects contextual fields (edition, cluster, etc.) so extension logs
// correlate with host logs without extra wiring.
Log() logr.Logger
}
Handle is the stable contract between the host and any extension.
The host implements Handle once during bootstrap and passes the same value to every Factory. Extensions take only what they need.
Keep the surface minimal. Adding a method is an ABI break for every out-of-tree extension, so prefer passing domain-specific dependencies via Args rather than widening Handle itself.