From an async file watcher in Python to a GenServer and mnesia in Elixir

From an async file watcher in Python to a GenServer and mnesia in Elixir

05 August, 2023 1 min read
Elixir, GenServer, API, product data management

I have been rewriting the API of TECTRA Ltd’s system for Product Data Management from Python to Elixir, as an exercise in learning Elixir, and Phoenix and GenServer in particular.

In the currently deployed, production versio in Python: an asyncio loop monitors a CSV file for modifications and (re-)loads it into an in-memory data structure. Queries for the various FastAPI endpoints take place with list comprehensions.

In the experimental Elixir version: a GenServer utilizes a FileSystem watcher on a path and asynchronously loads (and, upon file modifications reloads) a CSV file with all product items into a Mnesia database, which can be queried with Memento.Query functions.

Memento is a simple and powerful interface to the Mnesia distributed database that comes standard with Erlang.