Last active
August 11, 2016 09:22
-
-
Save pareeohnos/f8667aec4db0a697c00703077a7777f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| =ERROR REPORT==== 11-Aug-2016::10:21:41 === | |
| ** Generic server schedule_ingestor terminating | |
| ** Last message in was fetch_schedule_data | |
| ** When Server state == #{timer => #Ref<0.0.4.267>} | |
| ** Reason for termination == | |
| ** {{case_clause,{nil,100,0,nil}}, | |
| [{'Elixir.Stream',do_resource,5,[{file,"lib/stream.ex"},{line,1099}]}, | |
| {'Elixir.Stream',run,1,[{file,"lib/stream.ex"},{line,494}]}, | |
| {'Elixir.MyGenServer', | |
| handle_info,2, | |
| [{file, | |
| "lib/gen_server_test/my_gen_server.ex"}, | |
| {line,23}]}, | |
| {gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,615}]}, | |
| {gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,681}]}, | |
| {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule MyGenServer do | |
| use GenServer | |
| def start_link(name) do | |
| GenServer.start_link(__MODULE__, [], name: name) | |
| end | |
| def init(state) do | |
| IO.puts "INIT" | |
| :hackney.start | |
| timer = Process.send_after(self(), :fetch_schedule_data, 1000) | |
| { :ok, %{ timer: timer } } | |
| end | |
| def handle_info(:fetch_schedule_data, %{ timer: timer } = state) do | |
| IO.puts "Fetch data started" | |
| Stream.resource(fn -> begin_download end, | |
| &continue_download/1, | |
| &finish_download/1) | |
| |> Stream.run | |
| { :noreply, state } | |
| end | |
| defp begin_download do | |
| IO.puts "Starting download" | |
| { nil, 100, 0, nil } | |
| end | |
| defp continue_download({ client, total_size, size, file } = p) do | |
| IO.puts "Continuing download" | |
| p | |
| end | |
| defp finish_download({ client, total_size, size, file } = p) do | |
| IO.puts "Finished download" | |
| nil | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment