So I have the following use case.
I have some code / modules that I want to run different versions of.
Let’s say I have a user, when they sign up - they interact with some code v0.
I now want to deploy new changes to the that code, but this first user should still interact with the code of v0. Another user with v1 and maybe some other on v2.
At some point in time the user could decide to update to v1 or v2, but it’s their decision.
I was thinking, if I could do something like:
Module.create(ModuleVersionX, module_contents, ...)
bytecode = capture_bytecode_of(ModuleVersionX)
save_bytecode_to database
// later
bytecode = capture_bytecode_from_db()
reload_module(bytecode)
My specific questions:
- how do I specify
module_contents
based on an existing compiled module? - I think I can use
@after_compile
to capture the bytecode of this new module? If I’m able to add this@after_compile
hook in themodule_contents
- I’m not sure how to load the bytecode again from the database.
- What are the catches of an approach like this?
I found the following topic that might be interesting, but the link in there doesn’t work anymore: Any ideas on how to generate compile-time module based on other modules?