Elixir Weekly Drip #3 and Exercise: Supervised RPN Calculator and Tape Printer [03.10.2017]
This week we crammed in a lot of OTP learning. To reinforce that work, we'll rebuild the RPN calculator from last week using GenServer, and add a Tape Printer to output the calculation as we go along. First, though, let's see some interesting links for the week.
- ElixirSchool has some great content covering OTP as well:
- Learn You Some Erlang (LYSE) is a fantastic book for learning Erlang itself, as well as the general principles behind the features that we regularly take advantage of.
This week we'll rebuild the RPN calculator from last week, using GenServer.
- You should make the same tests pass, but with a GenServer backing it.
- Then Supervise it so that if it crashes it gets restarted (maybe division by zero should crash it?).
- Finally, add a
Tape PrinterGenServer as a dependency earlier in the Supervisor, give it a name, and have your calculator send it messages that it will print out - to a file, to the console, or wherever.
- If you want extra work, add a feature using GenStateMachine to switch the Tape
just resultsmode - where it only prints out reduced calculations, rather than each entry that's sent to it.
- If you want extra work, add a feature using GenStateMachine to switch the Tape Printer into