Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added typespecs to engine #36

Merged
merged 3 commits into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/crawly/engine.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,26 @@ defmodule Crawly.Engine do

use GenServer

@type t :: %__MODULE__{started_spiders: started_spiders()}
@type started_spiders() :: %{optional(module()) => identifier()}

defstruct started_spiders: %{}

@spec start_spider(module()) ::
:ok
| {:error, :spider_already_started}
| {:error, :atom}
def start_spider(spider_name) do
GenServer.call(__MODULE__, {:start_spider, spider_name})
end

@spec stop_spider(module()) ::
:ok | {:error, :spider_not_running}
def stop_spider(spider_name) do
GenServer.call(__MODULE__, {:stop_spider, spider_name})
end

@spec running_spiders() :: started_spiders()
def running_spiders() do
GenServer.call(__MODULE__, :running_spiders)
end
Expand All @@ -26,6 +36,7 @@ defmodule Crawly.Engine do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end

@spec init(any) :: {:ok, __MODULE__.t()}
def init(_args) do
{:ok, %Crawly.Engine{}}
end
Expand Down