Working through “Property Based Testing in PropEr with Erlang and Elixir” in Elixir – Part 2

I have returned to this book now that the book is out of beta.

I also started using a different repo:

The only difference between my code and the samples is that I am using the pipe syntax where possible. My Execism.IO background in Elixir is also forcing me to make style changes to keep the code in Elixir format.

Part 1 chapter 4 does use the erlang queue library. It would be good to be able to get Elixir documentation on erlang packages.

The part 2 sample code is broken but I am working on fixing in my repo.

It turned out to be easier to download the code from the pragprog site.

Designing Elixir Systems With OTP – Part Two

I have continued working through this beta book and have updated the github repo: with the samples.

So far this book is easier to follow than say Programming Phoenix since it does not keep changing the code that you are working on. The testing code is normally close to where you have typed it, so finding mistakes does not require too much effort. I would recommend using mix test after each code sample has been typed in as fixing errors can be tricky.

Note the only difference between my code and the supplied sample is the use of the british name Maths rather than Math for the sample code. My degree is in Mathematics so I can’t let a typo like that stand!

The main points from the second half of the book are the very clean validation techniques used. I like that they called the process returned by start_link a session.

The book currently stops at the end of chapter 6, so I will have to resume work on this series once it has been updated.

Designing Elixir Systems With OTP – Part One

These are my notes as I am working my way through this book from PragProg. I am reading a beta version of the book so things may change. I’ll be posting this to my github repo: (

The introduction starts by building a simple counter application as the domain and wraps it in a send/receive process with an API.

The code samples here are clean and clearly ordered. The only note that I have found so far is that I needed to delete the autogenerated Count.ex file to avoid a warning.

Takeaway from the intro: Supervisors are about lifecycles.

Takeaway from type introductions: Send the functions to the data!

Chapter 3 typo: response.ex is misspelt (reported).

excoveralls looks to be a better code coverage tool.

Essential Docker and Docker-Compose Commands

I spent some of today trying to work out why a Docker image that I was using did not work correctly.

This is the most useful command for debugging a docker image:

docker run -it ubuntu /bin/bash

This is based upon the ubuntu image but feel free to replace it with whatever you are trying to debug.

You can do the same with a docker-compose

docker-compose run --entrypoint /bin/bash

I am now looking at how to run a gradle build inside a docker container and then extract the log files. It will be especially useful to be able to view the log files. It may be possible to add a web server to view them.

It’s now also possible to stand up a Jenkins server on your dev machine to test Jenkinsfiles before deploying them to the build server.

docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts

Designing for Scalability with Erlang/OTP using Elixir – Part 2

Chapter 4

I am still working my way through this book.

The main difficulty that I am finding with chapter 4 is the scattered nature of the example code. It’s all small snippets, some of which references code in the previous chapter.

This is in addition to the Erlang => Elixir translations:

  • atom => :atom
  • VariableName => variable_name
  • moduleName => ModuleName

Some of the Elixir functions are reordered for consistency.

1> gen_server:start_link({local, timeout}, timeout, [], []).

1> c "Timeout.ex"
2> GenServer.start_link(Timeout, [], name: :timeout)
3>, {:sleep, 100})
4>, {:sleep, 5001})

The GenServer will by default timeout if a message takes more than 5 seconds to respond.

Samples for Chapter 4 have been pushed to with hash: cc8dd44

Chapter 5

The Erlang sys module can be reference from iex using :sys

The the log commands require atoms.

:sys.log(Frequency, :print)

:sys.log(Frequency, :get)

Now at hash: 830c1ea

Chapter 6

This is an odd chapter for Elixir as the Finite State Machine was considered defective and was not adapted as a wrapper. I am going to skip this chapter

Chapter 7

GenEvent has also been Deprecated

Designing for Scalability with Erlang/OTP using Elixir – Part 1

This is another of my book walk through series. This time I am working on Designing for Scalability with Erlang/OTP.

This is the book that goes into detail about OTP in general.

Chapter 2 : Introducing Erlang (edc0862)

The above is a repo with commit hash of where I have currently got to.

So far we have some basic recursion and some manual send/receive logic.

We have now seen the first use of ets – Erlang Term Storage a simple persistence layer.

Notes from Twitter

You build it you support it (even if not first line). It’s the other side of continuous delivery. You also need the right to fix anything that could wake you up. It focuses the developers minds to proper testing, logging, auditing and error handling. There is no wall.

Management frequently believes that the value of the advice is proportional to the cost. Also, knowledge gained outside an organisation is more valuable than that gained within.