Skip to content
This repository has been archived by the owner on Dec 27, 2020. It is now read-only.

Commit

Permalink
ISSUE-#1: fixed spacing for config and spat out some queue logic
Browse files Browse the repository at this point in the history
  • Loading branch information
howdoicomputer committed Jan 30, 2017
1 parent 07c5a18 commit 79e3323
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ config :calidrought, Calidrought.Repo,
database: "calidrought_dev",
hostname: "localhost",
pool_size: 10,
types: Calidrought.PostgresTypes
types: Calidrought.PostgresTypes
27 changes: 27 additions & 0 deletions lib/crawler/cdec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Calidrought.Crawler.Cdec do
use GenServer
require Logger

# Queue logic.

def start_link do
queue = initial_queue()
GenServer.start_link(__MODULE__, queue)
Expand All @@ -15,4 +17,29 @@ defmodule Calidrought.Crawler.Cdec do
defp schedule_work do
Process.send_after(self(), :work, 1 * 1 * 100)
end

def handle_info(:work, queue) do
new_queue = case :queue.out(queue) do
{{_value, item}, queue_2} ->
process(item, queue_2)
_ ->
Logger.debug "Queue is empty - restarting queue."
initial_queue()
end

schedule_work()

{:noreply, new_queue}
end

def process({}, queue) do
IO.puts "oh my goodness"
queue
end

# Parsing logic.

def initial_queue do
IO.puts "oh my goodness"
end
end

0 comments on commit 79e3323

Please sign in to comment.