Concurrent Data Processing In Elixir: Chapter 3 Errata

Towards the end of Chapter 3 (B2) the via function is implemented as:
def via(id) do
{{:via, Registry, {ProducerConsumerRegistry, id}}, []}
end

However the app fails to start unless you change this to:

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

Here is the code that I entered as specified in the book: GitHub - chriseyre2000/scraper: Sample app from chapter 3 of Concurrent Data Processing In Elixir

I did restart this chapter from B1 just in case something had changed/been fixed.

1 Like

Thank you for reporting this Christopher! And thanks for sharing the code, it was super helpful.

Looks like I made a mistake when introducing this. Rather than using {{:via, Registry, {ProducerConsumerRegistry, id}}, []} the book should ask you to modify page_consumer_supervisor.ex and update the subscribe_to options like so:

    opts = [
      strategy: :one_for_one,
      subscribe_to: [
        {OnlinePageProducerConsumer.via("online_page_producer_consumer_1"), []},
        {OnlinePageProducerConsumer.via("online_page_producer_consumer_2"), []}
      ]
    ]

However, you can still keep the code that you have at the moment. You’ll just get a warning message like this:

[warn]  :subscribe_to value with type {:via, module(), term()} is deprecated

I’ll make sure this is fixed in the next version :+1: