-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
grpc : Dynamic plugin loading #143
Conversation
For now conf file is kept simple with plugin name in each new line, other option is to have xml file and have xml parser included. |
We will have a xml parser included once the camera definition stuff is added that you could use. |
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.
Cool, thanks @Rjasuja. I think this is going in the right direction. I left some comments about next steps that I see.
grpc/python_client/CMakeLists.txt
Outdated
--python_out=. | ||
--grpc_python_out=. | ||
${proto_dir}/telemetry.proto | ||
DEPENDS ${proto_dir}/telemetry.proto |
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.
With cmake you can list all files in a directory and loop over them.
grpc/server/CMakeLists.txt
Outdated
--plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} | ||
--cpp_out=. ${proto_dir}/action.proto | ||
DEPENDS ${proto_dir}/action.proto | ||
) |
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.
Also, here I suggest to loop over the files automatically.
grpc/server/dronecore_server.cpp
Outdated
|
||
}; | ||
|
||
class ActionRPCImpl final : public ActionRPC::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.
I think these classes should be in separate files and then inside the respective plugin folder.
grpc/proto/mission.proto
Outdated
@@ -0,0 +1,51 @@ | |||
syntax = "proto3"; |
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.
I think these proto files should be moved to the respective plugin folders.
grpc/server/dronecore_server.cpp
Outdated
map_type map; | ||
map["action"] = &createInstances<ActionRPCImpl>; | ||
map["mission"] = &createInstances<MissionRPCImpl>; | ||
map["telemetry"] = &createInstances<TelemetryRPCImpl>; |
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 will need to be auto-generated in the same way as the plugins are currently added to device_impl.
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.
Do you agree?
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.
@julianoes createInstance takes class name as parameter, if not here somewhere there should be mapping between string to class name. Any other way we could do without hardcoded mapping.
Thanks for the review, we will address other comments in next submission.
@julianoes Can you review the changes. If this is fine, we can go ahead for multiple device handling implementation through gRPC. |
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.
I left a some comments. If you can address them or at least add todos, I think it's fine to merge this and move ahead.
grpc/server/CMakeLists.txt
Outdated
mission.pb.cc # generated | ||
mission.grpc.pb.cc # generated | ||
telemetry.pb.cc # generated | ||
telemetry.grpc.pb.cc # generated |
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.
You could also generate that list using the same foreach
. You just add it to all to a variable.
grpc/server/dronecore_server.cpp
Outdated
map_type map; | ||
map["action"] = &createInstances<ActionRPCImpl>; | ||
map["mission"] = &createInstances<MissionRPCImpl>; | ||
map["telemetry"] = &createInstances<TelemetryRPCImpl>; |
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.
Do you agree?
rpc Land(ActionEmpty) returns(ActionResult) {} | ||
} | ||
|
||
// FIXME these different Empty types are ugly |
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.
I think there is a protobuf empty that we should reuse: import "google/protobuf/empty.proto";
.
rpc TelemetryPositionSubscription(TelemetryEmpty) returns(stream TelemetryPosition) {} | ||
} | ||
|
||
message TelemetryEmpty {} |
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.
Also re-use empty here.
Same comments as @julianoes , thanks for the PR @Rjasuja |
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.
Only one small comment.
|
||
using grpc::Status; | ||
using grpc::ServerContext; | ||
using dronecorerpc::ActionRPC; | ||
using dronecorerpc::ActionEmpty; | ||
using dronecorerpc::Empty; |
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.
Is this line still needed?
Removed. |
@julianoes Added cmake file for automated generation of plugin objects. Please review. |
@Rjasuja cool thanks, this looks better! Can you merge or rebase with develop and check the CI issues please? |
Split proto files(one for each plugin), load plugins based on plugins.conf file
Modify Cmake to automatically generate plugins Move respective plugins in specific directories
Create a list of generated source files for all the plugins
Add plugin name in plugins.conf to enable the plugin Mapping table will generate object for the respective plugin and register the service
Thanks @Rjasuja! |
Split proto files(one for each plugin), load plugins based on plugins.conf file