Skip to content
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

Add a plugin mechanism to resource_retriever #103

Open
wants to merge 6 commits into
base: rolling
Choose a base branch
from

Conversation

mjcarroll
Copy link
Member

The idea behind this is to make resource_retriever pluggable. That is that downstream users of the library can choose the mechanisms that they want to back the calls to "get".

This will allow for things like retrieving over ROS services or parameters.

@mjcarroll mjcarroll requested review from wjwwood and sloretz August 16, 2024 19:54
@mjcarroll mjcarroll self-assigned this Aug 16, 2024
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, it's the best way to avoid resource retriever from being dependent on large things like ROS, while also keeping it somewhat easy to integrate into other non-ROS projects for relatively simple things like file:/// and package:/// urls.

@ahcorde ahcorde added the ros2 label Aug 20, 2024
@mjcarroll mjcarroll marked this pull request as ready for review December 3, 2024 16:07
Signed-off-by: Michael Carroll <[email protected]>
{
CURLcode ret = curl_global_init(CURL_GLOBAL_ALL);
if (ret != 0) {
std::cerr << "Error initializing libcurl! retcode = " << ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw an exception here? That way we wouldn't need the initialized_ variable at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue is that this is used a static global, so it's not possible to catch the exception.

However, I agree this isn't great.

I considered at least saying it should go through some injectable logging (so we could pipe it to ROS logging for example), but that's hard too since this is a global.

I think maybe it shouldn't print anything and instead it should just set the flag and the first place to try and use it should throw an exception since it's not initialized.

But I'll have to think about it more.

Comment on lines +33 to +39
#include <array>
#include <cstring>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <array>
#include <cstring>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <iostream>
#include <memory>
#include <string>
#include <utility>
#include <vector>


bool CurlRetriever::can_handle(const std::string & url)
{
return url.find("package://") == 0 ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return url.find("package://") == 0 ||
return url.find("package://") == 0 ||

Comment on lines +31 to +37
#include <array>
#include <cstring>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <array>
#include <cstring>
#include <fstream>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <fstream>
#include <memory>
#include <string>
#include <vector>


#include "resource_retriever/plugins/retriever_plugin.hpp"

#include <cstring>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <cstring>
#include <cstring>
#include <string>

Comment on lines 31 to 35
#include <cstring>
#include <memory>
#include <string>
#include <utility>
#include <vector>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <cstring>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <memory>
#include <string>
#include <utility>

@@ -31,16 +31,26 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <memory>
#include <vector>

(and alphabetize it with the above)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants