Sim

Sim

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.

Thanks!

Most Liked

montanonic

montanonic

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:

jgood

jgood

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.
http://erlang.org/doc/man/heart.html

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

We're in Beta

About us Mission Statement