the-little-elixir-otp-guidebook-code icon indicating copy to clipboard operation
the-little-elixir-otp-guidebook-code copied to clipboard

Chapter 8 - Blitzy implementation is different from the repo?

Open sashaafm opened this issue 9 years ago • 5 comments

Hello, Blitzy's implementation from the book seems different from the repo. The version in the book has a start/2 function because Blitzy.Caller passes its PID in order to get the results back to it.

Which version is the correct one? Maybe the chapter 8 in the book still hasn't been finalized?

Thanks

sashaafm avatar Aug 11 '16 19:08 sashaafm

I agree - I am looking at the example code, and it looks like much of it is written into the cli file, whereas the book has most of these functions implemented inside.

I've been trying, but I still can't get this working correctly: https://github.com/zeroasterisk/blitzy

iex(alan@alan-MBP)1> Blitzy.do_requests(10, "https://www.google.com", [:"alan@alan-MBP"])
Pummelling https://www.google.com with 10 requests from #PID<0.190.0>

23:37:52.354 [info]  Pummelling https://www.google.com with 10 requests from #PID<0.190.0>
** (exit) exited in: GenServer.call({TasksSupervisor, :"alan@alan-MBP"}, {:start_child, [#PID<0.190.0>, :monitor, {:"alan@alan-MBP", #PID<0.190.0>}, {Blitzy.Worker, :start, ["https://www.google.com", #PID<0.190.0>]}]}, :infinity)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir) lib/gen_server.ex:729: GenServer.call/3
    (elixir) lib/task/supervisor.ex:255: Task.Supervisor.do_async/5
    (elixir) lib/enum.ex:1233: anonymous fn/3 in Enum.map/2
    (elixir) lib/enum.ex:1785: Enum.reduce_range_inc/4
    (elixir) lib/enum.ex:1760: Enum.map/2
    (elixir) lib/enum.ex:966: Enum.flat_map_list/2
    (blitzy) lib/blitzy.ex:18: Blitzy.do_requests/3

zeroasterisk avatar May 10 '17 03:05 zeroasterisk

@zeroasterisk try adding alias Blitzy.TasksSupervisor in blitzy/lib/blitzy.ex

ziazek avatar May 13 '17 06:05 ziazek

@ziazek I am also experiencing the same problem with @zeroasterisk . Tried the alias and it still doesn't work.

Exegetech avatar Aug 23 '17 01:08 Exegetech

@zeroasterisk @christiansakai You all may have figured this out by now, but for posterity's sake: this error pops up for me whenever I forget to include the app itself in mix.exs (so it is started at runtime). You have to make sure that you have

def application do
  mod: {Blitzy, []},
  # extra_applications, etc
end

in mix.exs

tat2133 avatar Sep 05 '17 16:09 tat2133

Adding the alias (from @ziazek) still gives me the error/stack trace @zeroasterisk posted above. Also, isn't what @tat2133 suggests already in the mix.exs code in the book, as well as on the book's GitHub site for the source code?

Anyone solved this yet?

eboCode avatar Feb 15 '19 01:02 eboCode