@OvermindDL1: hmm, as far as I know (understand how it works):
I think that any file that is valid for Elixir compiler (again, see that or similar function) is good. Server needs to have only compiled my library as dependency (to compile macros used in such file). Nothing stops you to use that method after any time.
I don't yet read about
Erlang Run-Time System Application (ERTS), so I can say nothing about it now.
Here are the steps to make it work:
- Add my library as dependency
- Compile your project with all dependencies
- Run project
- On specified action (like form submit) call your plug-in loader mode for example:
4.0 Download source file if needed
4.1 Call function that compiles it
4.2 Call my library registration method to initialize API and/or it's implementations.
My registration method requires only module name + of course registering API before its implementations. It does not checks if module is loaded or not.
Also I currently don't have implemented a way to restore it's state (in case restart application), but you can add into database boolean field and simply for each plug-in that is enabled - enable it at start-up.
However I implemented ability to auto-register already compiled (in project) APIs and implementations, (by standard Elixir configuration), so in normal (not dynamically loading code) way you do not need to call register function for each your module.
If you want I can also add ability to restore state (for example save module names of APIs and implementations to two files and at start-up read that files and try to auto-register modules).
The question is:
What should I do if I can restore state and have specified modules in configuration?.
I can merge them (so I will have defaults + dynamically added) or load only from that two files skipping configuration (in case some of defaults were unregistered).
We talked also about security for plug-ins and I don't believe that this is good way to load plug-ins from untrusted source.
Note: I'm using
GenServer to keep my state.
I don't written yet code that sync any data across all nodes. I only created setup of 3 nodes that automatically talked with each other, but I only specified them
invm.args` and don't used any function to send message. Do you have an example to dispatch message for other nodes and add handler for that message?