@@ -71,7 +71,7 @@ provider, err := providerapi.GetTyped[*nico.Provider](
7171
7272``` go
7373type ComponentManager interface {
74- Type () devicetypes. ComponentType
74+ Descriptor () cmcatalog. Descriptor
7575 InjectExpectation (ctx, target, info) error
7676 PowerControl (ctx, target, info) error
7777 FirmwareControl (ctx, target, info) error
@@ -88,17 +88,21 @@ type ManagerFactory func(providers *providerapi.ProviderRegistry) (ComponentMana
8888
8989Factory functions create component manager instances. They receive the `ProviderRegistry` to retrieve any required providers.
9090
91+ `catalog.Descriptor` contains static implementation metadata used for
92+ configuration validation. `FactorySpec` pairs that descriptor with the runtime
93+ factory used after service config has been loaded.
94+
9195### Catalog and Registry
9296
93- The `Catalog` stores validated descriptors for implementations compiled into a
94- service binary:
95- - `NewCatalog ()` - Validate descriptors and index them by component type and
97+ The `catalog. Catalog` stores validated descriptors for implementations compiled
98+ into a service binary:
99+ - `catalog.New ()` - Validate descriptors and index them by component type and
96100 implementation
97101- `ListImplementations()` - List supported implementations by component type
98102
99- The `Registry` stores active managers selected from a catalog :
103+ The `Registry` stores active managers selected from runtime factory specs :
100104- `NewRegistry()` - Create managers based on configuration and the supplied
101- catalog
105+ factory specs
102106- `GetManager()` - Retrieve active manager for a component type, returning a
103107 descriptive error when the registry is not configured or no manager is active
104108- `GetDescriptor()` - Retrieve the descriptor selected for a component type
@@ -108,7 +112,9 @@ The `Registry` stores active managers selected from a catalog:
108112
109113```
110114internal/task/componentmanager/
111- ├── componentmanager.go # ComponentManager interface, Registry
115+ ├── manager.go # ComponentManager interface
116+ ├── factory_spec.go # Manager factories and factory specs
117+ ├── registry.go # Active component manager registry
112118├── providerapi/ # Provider interfaces and registries
113119├── config.go # Configuration parsing
114120├── mock/
@@ -235,7 +241,7 @@ func serviceProviderConfigDecoders() []providerapi.ProviderConfigDecoder {
235241` cmd/serve.go ` does not need provider-specific construction code. It loads the
236242service config through ` builtin.LoadConfig ` , then creates providers from the
237243decoded generic provider configs. Built-in provider decoders and component
238- manager factory registration both live in ` internal/task/componentmanager/builtin ` .
244+ manager factory specs both live in ` internal/task/componentmanager/builtin ` .
239245
240246---
241247
@@ -255,6 +261,7 @@ import (
255261 " fmt"
256262
257263 " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager"
264+ cmcatalog " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/catalog"
258265 " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/providerapi"
259266 myapiprovider " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/providers/myapi"
260267 " github.com/NVIDIA/infra-controller-rest/flow/internal/task/executor/temporalworkflow/common"
@@ -287,18 +294,25 @@ func Factory(providers *providerapi.ProviderRegistry) (componentmanager.Componen
287294}
288295
289296// Descriptor returns this implementation's descriptor.
290- func Descriptor () componentmanager .Descriptor {
291- return componentmanager .Descriptor {
297+ func Descriptor () cmcatalog .Descriptor {
298+ return cmcatalog .Descriptor {
292299 Type: devicetypes.ComponentTypeCompute ,
293300 Implementation: ImplementationName,
294301 RequiredProviders: []string {myapiprovider.ProviderName },
295- Factory: Factory,
296302 }
297303}
298304
299- // Type returns the component type.
300- func (m *Manager ) Type () devicetypes .ComponentType {
301- return devicetypes.ComponentTypeCompute
305+ // FactorySpec returns this implementation's runtime factory spec.
306+ func FactorySpec () componentmanager .FactorySpec {
307+ return componentmanager.FactorySpec {
308+ Descriptor: Descriptor (),
309+ Factory: Factory,
310+ }
311+ }
312+
313+ // Descriptor returns this implementation's descriptor.
314+ func (m *Manager ) Descriptor () cmcatalog .Descriptor {
315+ return Descriptor ()
302316}
303317
304318// InjectExpectation implements ComponentManager.
@@ -324,15 +338,26 @@ Update the service-supported manager catalog in
324338
325339``` go
326340import (
341+ " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager"
342+ cmcatalog " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/catalog"
343+ cmconfig " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/config"
327344 myimpl " github.com/NVIDIA/infra-controller-rest/flow/internal/task/componentmanager/compute/myimpl"
328345)
329346
330- func serviceCatalog ( config cmconfig . Config ) ( componentmanager . Catalog , error ) {
331- descriptors := []componentmanager .Descriptor {
347+ func serviceDescriptors () [] cmcatalog . Descriptor {
348+ descriptors := []cmcatalog .Descriptor {
332349 // ... existing descriptors ...
333350 myimpl.Descriptor (), // Add new implementation
334351 }
335- return componentmanager.NewCatalog (descriptors)
352+ return descriptors
353+ }
354+
355+ func serviceFactorySpecs (config cmconfig .Config ) ([]componentmanager .FactorySpec , error ) {
356+ factorySpecs := []componentmanager.FactorySpec {
357+ // ... existing factory specs ...
358+ myimpl.FactorySpec (), // Add new implementation
359+ }
360+ return factorySpecs, nil
336361}
337362```
338363
0 commit comments