Concurrent Data Processing In Elixir (B4) Part 2

Chapter 1 was about Tasks

Now working on Chapter 2

This implements a Job Control system (with retries) using a GenServer.

This builds a more complex setup for supervisor trees.

This introduces a DynamicSupervisor and then adds transitory supervisors that watch their own jobs (which can then terminate cleanly.

Here is the sample from chapter 2:

The important detail here is the use of a Registry, which exposes the underlying ETS (Erlang Term Storage) system used.

Concurrent Data Processing In Elixir (B4)

Now that the book has reached the sent to print stage I am again working through it.

Here is the repo containing the samples from the first chapter:

The first chapter works through the simplest solution to concurrency: Tasks.
It starts with a simple slow example and step by step adds more sophistication until you get to have a Task.Supervisor watching the code.

This is one of the more elegant examples of demoing the power and simplicity of Elixir tasks that I have seen.

Some Useful Aliases

I have started to add custom aliases to my bash setup to reduce typing time:

alias ism="iex -S mix"

This is great for turning code into an interactive session

alias mtp="mix test --include pending"

This allows quick testing of Elixir Exercism exercises.

Testing Your System As A Chain

A given software system is a series of components that need each other to work. To test it you can either test all of it or you can treat it like a chain and test each link.

The current system I work on has a database, a Java backend, JSP views and uses AngularJS in the front-end

In order to comprehensivly test it you need a range of components. Featupent re flags can be tested by asserting that the page has certain elements present or absent. You can test for the presence of a given angular tag.

The angular components can be tested in a unit test framework in isolation.

Protractor is useful for checking that the components hang together without errors. There are so many places that JavaScript can live that only by looking for errors on the logs or ensuring that the page still has interactivity can you be sure you have s functioning page.

I spent some of last year looking for these assertiobs in React only to find them in an angular library.