-
Notifications
You must be signed in to change notification settings - Fork 299
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
[ESI Runtime] Load backends as plugins #7260
Conversation
If a backend isn't found in the registry, try to load it dynamically from some standard places. Note that if one doesn't want to keep the plugin shared lib in one of those places, one can LD_PRELOAD it. Linux support only. Windows to come.
c556067
to
7cb376b
Compare
#endif | ||
} | ||
|
||
static void loadDynamic(string backend) { |
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.
-
const std::string&
my eyes always go oogley reading files withusing namespace std
;. -
Suggesting function rename to
loadBackend
+ add a small comment. -
I think there should be two functions; one as is (which tries to infer the backend path), and one which takes an absolute path to a backend. I'd imagine there should also be some option for users of ESI to manually provide the path to a backend, instead of relying on relative directory and backend name heuristics.
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.
const std::string&
my eyes always go oogley reading files withusing namespace std
;.
Yeah, using namespace std
is a bad habit I got into when first learning C++ in high school.
Can't use const since the string gets modified.
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.
3. I think there should be two functions; one as is (which tries to infer the backend path), and one which takes an absolute path to a backend. I'd imagine there should also be some option for users of ESI to manually provide the path to a backend, instead of relying on relative directory and backend name heuristics.
I think it's fair to use LD_PRELOAD for other non-standard path plugins.
loadDynamic(backend); | ||
f = internal::backendRegistry.find(backend); | ||
if (f == internal::backendRegistry.end()) | ||
throw runtime_error("Backend not found"); | ||
} |
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.
A bit in extension of the above; i fear this is some hard-to-debug code, in case there is a naming mismatch somewhere in the whole backend code registration/library naming.
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'll add a note to add debug logging when we get a logging framework.
If a backend isn't found in the registry, try to load it dynamically from some standard places. Note that if one doesn't want to keep the plugin shared lib in one of those places, one can LD_PRELOAD it.
Linux support only. Windows coming.