# Concurrent Data Processing in Elixir: various errata

**URL:** <https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769>\
**Category:** PragProg Customers\
**Tags:** book-concurrent-data-processing-in-elixir, errata\
**Created:** [6 February 2021 13:43 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769 "2021-02-06T13:43:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [6 February 2021 13:43 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/1 "2021-02-06T13:43:27Z")

</div>

Hi @Margaret ,

On page `VII` the book tells us the example and snippets will be all using Elixir version `1.11`

But on page `3` almost the end of the page when has a print of the `IEx` console, the version of the Elixir is `1.9.4` instead of `1.11`.

* * *

So and the most part of the book suggest use the `recompile` function on `IEx`, but sometimes after you change your code you continue to receive `:noop` on `IEx`, maybe change the approach to use the `r` function, e.g., `r(Sender)`, will be more efficient, using this way I tell recompile the `Sender` module on my application and no matter what if I change my code or not.

---

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [7 February 2021 06:09 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/2 "2021-02-07T06:09:23Z")

</div>

On page `26` after start the `IEx`, the `Elixir` version is `1.9.4`.

* * *

On page `31`:

```elixir
iex> {:ok, pid} = GenServer.start(SendServer, [max_retries: 1])
Received arguments: [limit: 1] # instead of limit: 1, it's need to be max_retries: 1

```

* * *

On page `32`:

```elixir
def handle_cast({:send, email}, state) do
  Sender.send_email(email)
  emails = [%{email: email, status: "sent", retries: 0}] ++ state.emails
  # it's missing update the state map and return the new state after update
  {:noreply, state}
end

```

* * *

On page `38`, maybe instead of called `%Jobber.Job{}` struct it could be change for `% __MODULE__ {}`.

* * *

On page `38`, it is has a private function called `random_job_id()`:

```elixir
defp random_job_id() do
  :crypto.strong_rand_bytes(5) |> Base.url_encode64(padding: false)
end

```

So, when called `:crypto` it’s necessary declare as a `extra_applications` on `mix.exs` file, look at on [Erlang libraries - The Elixir programming language](https://elixir-lang.org/getting-started/erlang-libraries.html#the-crypto-module)

---

<div class="post-metadata">

**Author:** ![svilen](https://forum.devtalk.com/user_avatar/forum.devtalk.com/svilen/32/529_2.png) [@svilen](https://forum.devtalk.com/u/svilen)\
**Post date:** [14 February 2021 14:34 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/3 "2021-02-14T14:34:11Z")

</div>

Thanks for taking the time to report these issues @herminiotorres! I’ve noted them all down and they’ll be fixed in the next beta version 👍

---

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [14 February 2021 19:24 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/4 "2021-02-14T19:24:13Z")

</div>

Hi @svilen ,

On page `64`, the `Logger.info` on `init` function it was declare like:

```elixir
Logger.info("Received demand for #{demand} pages")

```

but when running the app on `IEx`, the console shows us:

```elixir
19:28:18.359 [info] PageProducer received demand for 1000 pages

```

* * *

On page `73`, when it was suggested to change the tuple for `:producer` to test buffering events, the loggers on console show messages like:

```elixir
[warn] GenStage producer PageProducer has discarded 2 events from buffer

```

But when I try to use the same tuple(`{:producer, initial_state, buffer_size: :infinity}`), I receive this output:

```elixir
iex(1)> PageProducer.scrap_pages(pages)

20:50:54.066 [info] Elixir.PageConsumer received ["google.com"]

20:50:54.066 [info] Elixir.PageConsumer received ["facebook.com"]

20:50:55.068 [info] Elixir.PageConsumer received ["apple.com"]
 
20:50:57.067 [info] Elixir.PageConsumer received ["netflix.com"]
 
20:50:58.069 [info] Elixir.PageConsumer received ["amazon.com"]
 
20:51:01.068 [info] Elixir.PageProducer received demand for 1 pages
 
20:51:03.070 [info] Elixir.PageProducer received demand for 1 pages

```

* * *

On page `83` when using the via tuple function.

```elixir
def via(id) do
  {:via, Registry, {ProducerConsumerRegistry, id}}
end

```

After start the `IEx` session, the `Logger` print this `warn`:

```elixir
21:35:00.121 [warn] :subscribe_to value with type {:via, module(), term()} is deprecated. Change {:via, Registry, {ProducerConsumerRegistry, "online_page_producer_consumer_1"}} to {{:via, Registry, {ProducerConsumerRegistry, "online_page_producer_consumer_1"}}, []} instead.

```

---

<div class="post-metadata">

**Author:** ![svilen](https://forum.devtalk.com/user_avatar/forum.devtalk.com/svilen/32/529_2.png) [@svilen](https://forum.devtalk.com/u/svilen)\
**Post date:** [14 February 2021 20:26 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/5 "2021-02-14T20:26:38Z")

</div>

@herminiotorres Awesome, all this makes sense. Just one thing I’d like to clarify:

> [@herminiotorres](#):
>
> On page `73`, when it was suggested to change the tuple for `:producer` to test buffering events, the loggers on console show messages like:
> 
> ```auto
> [warn] GenStage producer PageProducer has discarded 2 events from buffer
> 
> ```
> 
> But when I try to use the same tuple(`{:producer, initial_state, buffer_size: :infinity}`), I receive this output:

I think you may have missed the following sentence, which says:

> Now, let’s do a quick experiment. Change buffer\_size to 1

Could you please try this and see if the output matches the example in the book?

I’ll try to improve this part, it could be more clear what’s expected 👍

---

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [18 February 2021 00:50 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/6 "2021-02-18T00:50:23Z")

</div>

Hi @svilen, I test changing to `buffer_size: 1`.

> [@svilen](#):
>
> I think you may have missed the following sentence, which says:
> 
> > Now, let’s do a quick experiment. Change buffer\_size to 1
> 
> Could you please try this and see if the output matches the example in the book?

And works well.

---

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [18 February 2021 01:25 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/7 "2021-02-18T01:25:50Z")

</div>

I like to share my thoughts about the book.

**Chapter 1:**  
I like your thoughts and perspective to use `Task` and `Task.Supervisor`, but maybe share how to create our own custom `Task.Supervisor`.

**Chapter 2:**  
I like the idea you use to create the `GenServer` and use it to improve the application to run `Task` on Chapter 1. It has good details about `GenServer` and the callbacks our module needs to implemented and introduce the last instructions about the `tuple` and the `spec` each callback receives as params. I feeling missing how to design the application supervisor tree, and how to think in perspective to guarantee our applications weren’t stop, maybe more content about `Registry` and how to use how to customize it and `Supervisor` and `DynamicSupervisor` too, the difference between both supervisors. The last thing is how to observe and debug, introducing this instrumentation when working with the `OTP.`

**Chapter 3:**  
I like the idea to drop into `GenStage` after the `GenServer` chapter because you are very fresh thoughts and very close to using these concepts for most GenServer applications. In this chapter, the knowledge about the supervisor tree is critical because you need to build how your entire stages need at least one process for each stage running. If some stage of my application it’s going down, the next or previous stage will fail. It could be more content about the `Dispatcher,` and I feel very quickly and small.

I like the application examples and how to use them to explain and conquer this knowledge about this abstract concept; sometimes it’s difficult to understand, a great book, and congrats. I’m very curious/excited about the next chapters and releases.

---

<div class="post-metadata">

**Author:** ![svilen](https://forum.devtalk.com/user_avatar/forum.devtalk.com/svilen/32/529_2.png) [@svilen](https://forum.devtalk.com/u/svilen)\
**Post date:** [18 February 2021 23:41 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/8 "2021-02-18T23:41:27Z")

</div>

Thank you for the kind words, and for sharing your ideas, Herminio! I really appreciate it!

---

<div class="post-metadata">

**Author:** ![vrcca](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/v/bcef8e/32.png) [@vrcca](https://forum.devtalk.com/u/vrcca)\
**Post date:** [20 February 2021 16:04 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/9 "2021-02-20T16:04:11Z")

</div>

In `Adjusting Restart Frequency`, it states

> By default, `max_restarts` is set to `3` and `max_seconds` to `5`"

Then it goes ahead asking us to set to `30` seconds. However, the code writes `max_seconds: 30_000` seconds which is **500 minutes.** It should be `max_seconds: 30` instead.

---

<div class="post-metadata">

**Author:** ![svilen](https://forum.devtalk.com/user_avatar/forum.devtalk.com/svilen/32/529_2.png) [@svilen](https://forum.devtalk.com/u/svilen)\
**Post date:** [20 February 2021 16:46 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/10 "2021-02-20T16:46:23Z")

</div>

Thanks for spotting this Vitor, I’ll make sure this is corrected 👍

---

<div class="post-metadata">

**Author:** ![dimitarvp](https://forum.devtalk.com/user_avatar/forum.devtalk.com/dimitarvp/32/5599_2.png) [@dimitarvp](https://forum.devtalk.com/u/dimitarvp)\
**Post date:** [20 February 2021 19:44 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/11 "2021-02-20T19:44:29Z")

</div>

Oh, just now noticed the book isn’t finished, or am I wrong?

I’d love to buy this in a physical form in addition to an `.epub` file. I’ll listen here on this forum for an announcement of the final paper version of the book.

---

<div class="post-metadata">

**Author:** ![Margaret](https://forum.devtalk.com/user_avatar/forum.devtalk.com/margaret/32/237_2.png) [@Margaret](https://forum.devtalk.com/u/Margaret)\
**Post date:** [25 February 2021 15:47 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/12 "2021-02-25T15:47:47Z")

</div>

@dimitarvp thanks – we are just in the first beta, so not yet in print. In print date should be August 2021.

---

<div class="post-metadata">

**Author:** ![herminiotorres](https://forum.devtalk.com/user_avatar/forum.devtalk.com/herminiotorres/32/570_2.png) [@herminiotorres](https://forum.devtalk.com/u/herminiotorres)\
**Post date:** [15 March 2021 21:30 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/13 "2021-03-15T21:30:40Z")

</div>

I started to reread the new beta version…

On page 15, when has the topic `Linking Processes`, maybe just “How Process Work”, and you could explain between:  
`nolink` =\> `spawn`  
`link` =\> `spawn_link`  
`monitor` =\> `spawn_monitor`  
What do you think?

In Chapter One, on the topic “Supervisor”, maybe you could do a little bit more instrumentation about why occur the `IEx` process died when it did yet use the `Task.Supervisor`.

Maybe show the supervise tree use `:observer.start()`, and follow the process going die when calling the `notify_all/1`.

After finish the first chapter, I like it more than I read it the first time.

Well done @svilen

---

<div class="post-metadata">

**Author:** ![drl123](https://forum.devtalk.com/user_avatar/forum.devtalk.com/drl123/32/125_2.png) [@drl123](https://forum.devtalk.com/u/drl123)\
**Post date:** [11 April 2021 17:34 UTC](https://forum.devtalk.com/t/concurrent-data-processing-in-elixir-various-errata/6769/14 "2021-04-11T17:34:47Z")

</div>

@svilen @Margaret In Beta 3, page 85, the via function was changed to `{{:via, Registry, {ProducerConsumerRegistry, id}}, []}`. This does not work. This should only be on the subscribe calls, not the actual name for the child process. The deprecation warning was on the subscription, not in the module useage itself.

Revert this to the original `{:via, Registry, {ProducerConsumerRegistry, id}}` and then where the subscription happens in page\_consumer\_supervisor.change2.ex, change the subscription entries to:

```elixir
subscribe_to: [
        {OnlinePageProducerConsumer.via("online_page_producer_consumer_1"), []},
        {OnlinePageProducerConsumer.via("online_page_producer_consumer_2"), []}
      ]

```
