Documentation
¶
Overview ¶
Package plugin provides the instance-owned host for compiled-in Dingo plugins. Subsystem service contracts remain in their owning packages; this package only coordinates provider selection, typed construction, and lifecycle.
Index ¶
- func ApplyEnvironment(capability Capability, selection *Selection, environ []string) error
- func EnvironmentPrefix(capability Capability) string
- func MissingProviderError(capability Capability, name string) error
- func Register[S, C, D any](host *Host, descriptor Descriptor, defaults func() C, factory Factory[S, C, D]) error
- func Resolve[S, D any](ctx context.Context, host *Host, capability Capability, name string, ...) (S, error)
- func ResolveProvider[D any](ctx context.Context, host *Host, capability Capability, name string, ...) error
- type Capability
- type Descriptor
- type Factory
- type Host
- type Instance
- type Lifecycle
- type Selection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEnvironment ¶
func ApplyEnvironment(capability Capability, selection *Selection, environ []string) error
ApplyEnvironment overlays generic plugin environment entries on a YAML selection. CLI provider selectors are intentionally applied by composition after this function, giving selector CLI > environment > YAML precedence.
func EnvironmentPrefix ¶
func EnvironmentPrefix(capability Capability) string
EnvironmentPrefix returns the generic environment prefix for capability.
func MissingProviderError ¶
func MissingProviderError(capability Capability, name string) error
MissingProviderError returns an actionable error for known providers that require the optional-provider build tag.
func Register ¶
func Register[S, C, D any]( host *Host, descriptor Descriptor, defaults func() C, factory Factory[S, C, D], ) error
Register adds a typed provider to host. defaults is called before strict decoding and may be nil when the zero value is the provider default.
func Resolve ¶
func Resolve[S, D any]( ctx context.Context, host *Host, capability Capability, name string, rawConfig map[string]any, deps D, ) (S, error)
Resolve constructs and starts one selected provider, returning its typed service. A provider that fails during startup is stopped before the error is returned. Previously started providers remain active so composition code can unwind them around non-plugin dependents in the correct order.
func ResolveProvider ¶
func ResolveProvider[D any]( ctx context.Context, host *Host, capability Capability, name string, rawConfig map[string]any, deps D, ) error
ResolveProvider constructs and starts a provider whose service has no in-process consumers. The host still owns its lifecycle, while the provider remains free to use a package-specific service type internally. This is useful for endpoint capabilities that only need to be started and stopped.
Types ¶
type Capability ¶
type Capability string
Capability is a stable identifier for a pluggable subsystem.
const ( CapabilityStorageBlob Capability = "storage.blob" CapabilityStorageMetadata Capability = "storage.metadata" CapabilityMempool Capability = "mempool" CapabilityAPIBlockfrost Capability = "api.blockfrost" CapabilityAPIMesh Capability = "api.mesh" CapabilityAPIUtxorpc Capability = "api.utxorpc" )
func (Capability) Valid ¶
func (c Capability) Valid() bool
Valid reports whether c is a capability supported by this platform.
type Descriptor ¶
type Descriptor struct {
Capability Capability
Name string
Description string
}
Descriptor describes a compiled-in provider.
type Factory ¶
Factory constructs a typed service and its lifecycle from typed configuration and dependencies.
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is an application-owned provider registry and lifecycle coordinator. A Host is safe for concurrent listing and resolution.
func (*Host) Providers ¶
func (h *Host) Providers() []Descriptor
Providers returns all registered providers in capability/name order.
func (*Host) Stop ¶
Stop stops all successfully started providers in reverse order. It is idempotent; subsequent calls return the first call's result.
func (*Host) StopCapability ¶
func (h *Host) StopCapability( ctx context.Context, capability Capability, ) error
StopCapability stops successfully started providers for one capability in reverse start order. It is idempotent and leaves other capabilities active, allowing composition code to preserve dependencies on non-plugin services.
func (*Host) ValidateSelection ¶
func (h *Host) ValidateSelection( capability Capability, name string, rawConfig map[string]any, ) error
ValidateSelection verifies that a provider exists and its configuration decodes strictly, without constructing or starting it.
type Instance ¶
Instance is the lifecycle owned by a Host. Start and Stop must honor the supplied context. Stop implementations should be safe to call more than once; Host also guarantees that it invokes each successful instance once.