Skip to content

Commit

Permalink
added draft logic comments for fetchers implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc committed Dec 10, 2019
1 parent e04dbe6 commit a1ef1a4
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/crawly/worker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ defmodule Crawly.Worker do
case :epipe.run(functions, {request, spider_name}) do
{:error, _step, reason, _step_state} ->
# TODO: Add retry logic
Logger.error(
fn ->
"Crawly worker could not process the request to #{inspect(request.url)}
Logger.error(fn ->
"Crawly worker could not process the request to #{
inspect(request.url)
}
reason: #{inspect(reason)}"
end)
end)

@default_backoff

{:ok, _result} ->
@default_backoff
end

end

Process.send_after(self(), :work, new_backoff)
Expand All @@ -66,6 +68,9 @@ defmodule Crawly.Worker do
response: HTTPoison.Response.t(),
result: {:ok, response, spider_name} | {:error, term()}
defp get_response({request, spider_name}) do
# check if spider-level fetcher is set. Overrides the globally configured fetcher.
# if not set, log warning for explicit config preferred, get the globally-configured fetcher. Defaults to HTTPoison

case HTTPoison.get(request.url, request.headers, request.options) do
{:ok, response} ->
{:ok, {response, spider_name}}
Expand Down

0 comments on commit a1ef1a4

Please sign in to comment.