-
Notifications
You must be signed in to change notification settings - Fork 113
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
RSDK-1627 - Add generic DoCommand support for modules #1732
Conversation
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.
Not sure we should error out on not having a generic subtype for a service, but I may be missing something.
if name.Subtype.ResourceType == resource.ResourceTypeComponent && name.Subtype != generic.Subtype { | ||
genSvc, ok := m.services[generic.Subtype] | ||
if !ok { | ||
return nil, errors.New("no generic service") |
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 probably is not an error right? a component may not implement generic
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 more about the generic subtype service missing, which should ALWAYS be there if a component model was ever registered (since it's unknown what specific models may or may not support generic, the service is just there as long as any component has been registered.) In theory this should be impossible to hit, but "abundance of caution" and all that.
If a component doesn't actually implement generic, then what will happen is the model itself will return "Unimplemented" if/when a generic (DoCommand) is actually tried on the resource or the service will error when trying to cast the resource. (This is effectively the same way things work in the main viam-server process.)
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.
Oh I see. Okay great then. Approving.
|
||
if cfg.API.ResourceType == resource.ResourceTypeComponent && cfg.API != generic.Subtype { | ||
genSvc, ok := m.services[generic.Subtype] | ||
if !ok { |
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.
same for these other two
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.
LGTM. Thanks for the quick fix
pretty excited about this! thanks james! |
|
Does what it says on the tin. I somehow overlooked this case (generic interface on regular components) during the main modules project. Thanks to @dannenberg for pointing it out.