...use GenServe4r
...
should be:
...use GenServer
...
This correction hasn't been made to avoid introducing new errors.
The Dict
module has been deprecated in favor of Map
. Therefore the examples might display a Warning this module is deprecated
warning. Simply replace Dict
with Map
.
In the example, the extra space should be removed to eliminate a "unexpected parentheses" warning:
MeterToLengthConverter.convert(:feet, "smelly")
Certain dependencies in Elixir must be started in a specific way; such dependencies are declared in the application
function.
The reset_stats
function definition is missing a closing )
:
GenServer.cast(@name, :reset_stats)
In order for the example to work, the reader must start from a fresh shell session. Therefore, the first paragraph should be:
Let's try to link a dead process to see what happens. First, make sure that you are starting from a fresh shell session. Then, create a process that exits quickly:
In the second callout, it should read:
Handles a message to detect :EXIT messages
The key can be retrieved like so:
should be:
The value can be retrieved like so:
Right after the listing, the sentence should read:
You begin by creating a supervisor:
Also, the pid of the supervisor is wrong. It should have been #PID<0.84.0>
.
If you're supervising a Supervisor
, then use supervise/3
.
Should be:
If you're supervising a Supervisor
, then use supervisor/3
.
The defstruct
listing on the second line should be removed.
In the last paragraph, Supevisor
should be Supervisor
.
There's an extra trailing A
on the following line:
monitors = :ets.new(:monitors, [:private])
The updated defstruct
has been omitted:
defstruct sup: nil, worker_sup: nil, monitors: nil, size: nil, workers: nil, mfa: nil,
... and paste the implementation of Pooly.Server
version 2 to Pooly.PoolyServer
.
should be:
... and paste the implementation of Pooly.Server
version 2 to Pooly.PoolServer
.
worker_opts
should be worker_opts = [shutdown: 5000, function: f]
. The original
options would have caused the workers not to retstart.
The State
struct is missing a waiting
field:
defstruct pool_sup: nil, ..., waiting: nil, overflow: nil, max_overflow: nil
There is reference to a non-existent waiting
field of the State
struct. See fix for Page 158, Listing 7.14
... became available and was handled to ...
should be
... became available and was handled by ...
In mix.exs
, a description of adding the :mod
option has been left out in the application/0
function. Omitting this would cause a ** (EXIT) no process
error when attempting to start the application.
There is an extraneous colon:
override: true:
The text mentions that func
is an optional parameter, though the code has no mention of this. It is safe to ignore that entire paragraph.
Also, because of a change in API in the Timex
library, all references to Timex.measure/1
should be changed to Duration.measure
instead.
Most of the code uses Blitzy.Worker.start/1
instead of Blitzy.Worker.start/3
.
Please use this version:
defmodule Blitzy.Worker do
use Timex
require Logger
def start(url) do
{timestamp, response} = Duration.measure(fn -> HTTPoison.get(url) end)
handle_response({Duration.to_milliseconds(timestamp), response})
end
defp handle_response({msecs, {:ok, %HTTPoison.Response{status_code: code}}})
when code >= 200 and code <= 304 do
Logger.info "worker [#{node}-#{inspect self}] completed in #{msecs} msecs"
{:ok, msecs}
end
defp handle_response({_msecs, {:error, reason}}) do
Logger.info "worker [#{node}-#{inspect self}] error due to #{inspect reason}"
{:error, reason}
end
defp handle_response({_msecs, _}) do
Logger.info "worker [#{node}-#{inspect self}] errored out"
{:error, :unknown}
end
end
The nodes
parameter should be omitted:
defp process_options(options) do
...
end
There is a step missing. In order to start the Chucky application in iex
, the
mod
option has to be filled up in application/0
in mix.exs
:
def application do
[applications: [:logger],
mod: {Chucky, []}]
end
The example omits the following helper functions:
def key do
oneof([int, real, atom])
end
def val do
key
end
def map do
lazy do
oneof [{:call, Map, :new, []},
{:call, Map, :put, [map_2, key, val]}]
end
end
At the bottom of the page, the code should be:
forall {i, l} <- {int, list(int)}
In the example at the bottom of the page, !
should be wrapped in double quotes like so:
join(["everything", "is", "awesome", "!"], [?|])
The third line of the code should be:
vector(len, frequency([{3, one_of(:lists.seq(?a, ?z))},
Instead of:
vector(len, frequency([{3, one of(:lists.seq(?a, ?z))},
In the last line of the section, the command to make sure that GraphViz is properly installed should be dot -V
. The remaining part, dot - graphviz version 2.38.0 (20140413.2041)
, is the expected response.