-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement initial discover service #4665
base: main
Are you sure you want to change the base?
Conversation
@@ -431,3 +431,5 @@ require ( | |||
github.com/ziutek/mymysql v1.5.4 // indirect | |||
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e | |||
) | |||
|
|||
replace go.viam.com/api => github.com/johnn193/api v0.0.0-20241231164642-99f059defc82 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will revert once api is merged
return discovery.NewRPCServiceServer(injectSvc).(pb.DiscoveryServiceServer), injectDiscovery, injectDiscovery2, nil | ||
} | ||
|
||
func TestDiscoveryDo(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is literally copy/paste from the generic service I should probably remove this test, but I'm also fine with leaving it in case we are worried this will somehow break
// this was taken from proto_conversion_test.go | ||
// | ||
//nolint:thelper | ||
func validateComponent(t *testing.T, actual, expected resource.Config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the same function as in proto_conversion_test.go
unsure if theres a good spot to put this function to use it in both spots, or if its fine to leave here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good with a few nits. I think we use pointers when we want to return structs very fast, check with Nick S if that return type should be changed to just an array of resource.Configs
rather than an array of pointers.
// Service describes the functions that are available to the service. | ||
type Service interface { | ||
resource.Resource | ||
DiscoverResources(ctx context.Context, extra map[string]any) ([]*resource.Config, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to return an array of pointers to resource.Configs? Or would it be okay to return []resource.Config
, since you can already return nil here?
} | ||
|
||
// Service describes the functions that are available to the service. | ||
type Service interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, surprised this is called Service
not discovery
since the components follow. different pattern. But whatever, the other services do this so let's keep that format.
configs, err := svc.DiscoverResources(ctx, req.GetExtra().AsMap()) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also have a check if configs are nil here, and also test that we error nicely in the server test.
SubtypeName = "discovery" | ||
) | ||
|
||
// API is a variable that identifies the slam resource API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// API is a variable that identifies the slam resource API. | |
// API is a variable that identifies the discovery resource API. |
Initial implementation of the discover service in Go. Currently working on GetModelsFromModules in a separate branch to make it easier on reviewers
ticket: https://viam.atlassian.net/browse/RSDK-9620