@@ -27,7 +27,6 @@ import (
27
27
"google.golang.org/grpc/codes"
28
28
"google.golang.org/grpc/credentials/insecure"
29
29
"google.golang.org/grpc/status"
30
- "google.golang.org/protobuf/types/known/structpb"
31
30
32
31
"go.viam.com/rdk/config"
33
32
"go.viam.com/rdk/ftdc"
@@ -88,7 +87,6 @@ type module struct {
88
87
sharedConn rdkgrpc.SharedConn
89
88
client pb.ModuleServiceClient
90
89
// robotClient supplements the ModuleServiceClient client to serve select robot level methods from the module server
91
- // such as the DiscoverComponents API
92
90
robotClient robotpb.RobotServiceClient
93
91
addr string
94
92
resources map [resource.Name ]* addedResource
@@ -627,19 +625,19 @@ func (mgr *Manager) Configs() []config.Module {
627
625
return configs
628
626
}
629
627
630
- // AllModels returns a slice of resource.ModuleModelDiscovery representing the available models
628
+ // AllModels returns a slice of resource.ModuleModel representing the available models
631
629
// from the currently managed modules.
632
- func (mgr * Manager ) AllModels () []resource.ModuleModelDiscovery {
630
+ func (mgr * Manager ) AllModels () []resource.ModuleModel {
633
631
moduleTypes := map [string ]config.ModuleType {}
634
- models := []resource.ModuleModelDiscovery {}
632
+ models := []resource.ModuleModel {}
635
633
for _ , moduleConfig := range mgr .Configs () {
636
634
moduleName := moduleConfig .Name
637
635
moduleTypes [moduleName ] = moduleConfig .Type
638
636
}
639
637
for moduleName , handleMap := range mgr .Handles () {
640
638
for api , handle := range handleMap {
641
639
for _ , model := range handle {
642
- modelModel := resource.ModuleModelDiscovery {
640
+ modelModel := resource.ModuleModel {
643
641
ModuleName : moduleName , Model : model , API : api .API ,
644
642
FromLocalModule : moduleTypes [moduleName ] == config .ModuleTypeLocal ,
645
643
}
@@ -1328,10 +1326,6 @@ func (m *module) registerResources(mgr modmaninterface.ModuleManager) {
1328
1326
case api .API .IsComponent ():
1329
1327
for _ , model := range models {
1330
1328
m .logger .Infow ("Registering component API and model from module" , "module" , m .cfg .Name , "API" , api .API , "model" , model )
1331
- // We must copy because the Discover closure func relies on api and model, but they are iterators and mutate.
1332
- // Copying prevents mutation.
1333
- modelCopy := model
1334
- apiCopy := api
1335
1329
resource .RegisterComponent (api .API , model , resource.Registration [resource.Resource , resource.NoNativeConfig ]{
1336
1330
Constructor : func (
1337
1331
ctx context.Context ,
@@ -1341,34 +1335,6 @@ func (m *module) registerResources(mgr modmaninterface.ModuleManager) {
1341
1335
) (resource.Resource , error ) {
1342
1336
return mgr .AddResource (ctx , conf , DepsToNames (deps ))
1343
1337
},
1344
- Discover : func (ctx context.Context , logger logging.Logger , extra map [string ]interface {}) (interface {}, error ) {
1345
- extraStructPb , err := structpb .NewStruct (extra )
1346
- if err != nil {
1347
- return nil , err
1348
- }
1349
-
1350
- //nolint:deprecated,staticcheck
1351
- req := & robotpb.DiscoverComponentsRequest {
1352
- Queries : []* robotpb.DiscoveryQuery {
1353
- {Subtype : apiCopy .API .String (), Model : modelCopy .String (), Extra : extraStructPb },
1354
- },
1355
- }
1356
-
1357
- //nolint:deprecated,staticcheck
1358
- res , err := m .robotClient .DiscoverComponents (ctx , req )
1359
- if err != nil {
1360
- m .logger .Errorf ("error in modular DiscoverComponents: %s" , err )
1361
- return nil , err
1362
- }
1363
- switch len (res .Discovery ) {
1364
- case 0 :
1365
- return nil , errors .New ("modular DiscoverComponents response did not contain any discoveries" )
1366
- case 1 :
1367
- return res .Discovery [0 ].Results .AsMap (), nil
1368
- default :
1369
- return nil , errors .New ("modular DiscoverComponents response contains more than one discovery" )
1370
- }
1371
- },
1372
1338
})
1373
1339
}
1374
1340
case api .API .IsService ():
0 commit comments