I made a thing for school, feedback appreciated!

Hello Elixir Forum!
First, a short introduction. I’m currently going to school, learning software development, and this week we have been able to do whatever we wanted, as long as it was approved by the teacher.
So I took the opportunity to immerse myself in functional programming and specifically Erlang and Elixir.
I have been interested in Elixir for a while and I have played around with IEx a bit, but never had time to really do anything with it, until this week.

There will be a small presentation tomorrow, where I will be showing what I have learned during the week.
For this I have made a small application, that’s supposed to show the easy concurrency that comes with Elixir and Erlang/OTP.

Github Link
The actual application is in the park_mon folder. park_mon_client is a Phoenix web app I quickly hacked together, in order to have something visually showing what is happening.

It’s basically a very simple parking monitoring system, where each monitor GenServer is supposed to represent a parking meter, covering between 5 and 15 parking spots.
The parking meters are grouped in different areas, represented by Supervisors.
I have also made a ‘simulator’ GenServer, so I can show the application in action.

I’m not sure the teacher knows anything of Elixir and Erlang/OTP, so I will probably not be receiving any feedback on the code of the application.
That’s why I’m turning to the forum.

I could use some feedback/criticism, specifically if there are any parts that show a complete lack of understanding about OTP.
Additionally, I’m unsure if the ETS lookup I’m doing in the init function of the monitors, is a prudent way to recover state, after a shutdown?
I had a hard time finding any resources about recovering state, that fit this simple example.



Hi! This is a question coming from only skimming the source. Could you elaborate on what some of the things the parking monitor system does, and how you thought through designing it at a high-level? Like, what do the parking meters do, what are you monitoring, what are you simulating?

Thanks for sharing! Happy that you got a chance to use Elixir more :slight_smile:


It basically just monitors free spots in each parking lot, and registers the license plates of the cars that are parked. The uuids I use are supposed to represent the license plates.
The simulator processes, simulate cars coming and going to the parking lots.

I didn’t really put a lot of thought into the overall design of the application, as I used this as an opportunity to learn and play around with Elixir and OTP.
I wanted to try out as many features as I could, so it probably won’t all make sense :smile:

This is something I also was curious about when I first started to look into GenServers.

If I’m not mistaken, ETS is another process in your application which is supervised, if it crashes, then it will lose state as well unless your rehydrate it from another datastore which is more durable than ETS.

There’s a github issue that is kind of asking the same thing that you are here, and it looks like the person asking the question opted for using redis.

Also, if you want to learn more about OTP Programming Erlang by Joe Armstrong is phenomenal.

One of the things I was also curious about when I was writing the small program that used a GenServer, was what to do if my entire Elixir application crashed.

Turns out there’s a flag which can be passed to handle this situation.

1 Like