aesmail

aesmail

I have a bit of an unconventional situation.

I have an app that generates files at runtime. Those files contain valid elixir code (modules basically). I need to compile them and load them at runtime.

I am able to do most of that with Code.compile_file, Code.require_file, and friends.

However, I need to be able to check what new modules have been compiled (or all the modules currently loaded in my app).

I’m using :application.get_key(:my_app, :modules) which lists all modules correctly when the app starts, but this doesn’t include the newly compiled modules at runtime.

Any idea how to achieve that?

All I care about is, I need to compile random modules at runtime and I need to know about all the newly generated modules that were compiled randomly at runtime.

Thanks!

Showing Posts 1 to 9

dimitarvp

dimitarvp

I seem to remember the core team saying that there are compiler callbacks or some such now but I am not able to immediately find anything on it.

aesmail

aesmail OP

Your comment made me dip deeper into erlang and I could :code.all_loaded() which provides a list of all loaded modules from all apps including dependencies. It’s not ideal, but it’ll do for now, but I’m still looking for a better way since this can potentially be an extremely large list.

hauleth

hauleth

You can add them to the list manually, however I am not sure if Mix will not overwrite it.

xlphs

xlphs

If you only care about newly compiled modules, and your app is the one that compiles and loads each module, you can store each module name or the file name into an Agent or your own GenServer.

axelson

axelson

Scenic Core Team

You might be able to glean something from GitHub - falood/exsync: Yet another elixir reloader. · GitHub

It watches the beam folder and loads new beam files it sees. It’s meant for development but that approach could be adapted to prod

aesmail

aesmail OP

This might just work. I’ll try it and report the result.

aesmail

aesmail OP

Thanks for the suggestion. This is definitely a workaround, but I would feel more comfortable if there was something built-in that could handle this. I believe there’s a way with the help of erlang modules but it’s not documented clearly.

Interesting package. I’m going to take a few ideas from this. Thanks!

OvermindDL1

OvermindDL1

Personally I’d have the files register themselves, you might have tools and such you don’t want loaded via your normal way as well after all. :slight_smile:

zaherh8

zaherh8

hello @aesmail, any luck with finding a way to load the newly compiled modules?
I am facing the same case where I need to compile different modules dynamically. I need to make sure that the modules are loaded and accessible. If you found any result please share thanks.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews