Skip to content

Commit

Permalink
Update specs for new dialyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaturan committed Aug 4, 2018
1 parent 9434b4e commit 379cbf8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions lib/event_bus.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ defmodule EventBus do
Topic
}

alias EventBus.Model.Event

@doc """
Send event to all subscribers(listeners).
Expand Down
15 changes: 8 additions & 7 deletions lib/event_bus/models/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,21 @@ defmodule EventBus.Model.Event do
* :ttl - Time to live value
"""
@type t :: %__MODULE__{
id: String.t() | integer,
transaction_id: String.t() | integer,
topic: atom,
data: any,
initialized_at: integer,
occurred_at: integer,
id: String.t() | integer(),
transaction_id: String.t() | integer(),
topic: atom(),
data: any(),
initialized_at: integer(),
occurred_at: integer(),
source: String.t(),
ttl: integer
ttl: integer()
}

@doc """
Duration of the event, and simple answer of how long does it take to generate
this event
"""
@spec duration(__MODULE__.t()) :: integer()
def duration(%__MODULE__{
initialized_at: initialized_at,
occurred_at: occurred_at
Expand Down
2 changes: 1 addition & 1 deletion lib/event_bus/services/notification.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ defmodule EventBus.Service.Notification do
end

@spec notify_listener(tuple(), tuple()) :: no_return()
@spec notify_listener(module(), tuple()) :: no_return()
defp notify_listener({listener, config}, {topic, id}) do
listener.process({config, topic, id})
rescue
Expand All @@ -38,6 +37,7 @@ defmodule EventBus.Service.Notification do
ObservationManager.mark_as_skipped({{listener, config}, topic, id})
end

@spec notify_listener(module(), tuple()) :: no_return()
defp notify_listener(listener, {topic, id}) do
listener.process({topic, id})
rescue
Expand Down
2 changes: 1 addition & 1 deletion lib/event_bus/services/observation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ defmodule EventBus.Service.Observation do
end

@doc false
@spec save(tuple(), tuple()) :: :ok
@spec save(tuple(), tuple()) :: no_return()
def save({topic, id}, watcher) do
save_or_delete({topic, id}, watcher)
:ok
Expand Down
8 changes: 3 additions & 5 deletions lib/event_bus/services/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ defmodule EventBus.Service.Subscription do
end

@doc false
@spec subscribers() :: list()
def subscribers do
{listeners, _topic_map} = load_state()
listeners
end

@spec subscribers(atom()) :: list()
def subscribers(topic) do
{_listeners, topic_map} = load_state()
topic_map[topic] || []
Expand Down Expand Up @@ -109,10 +111,6 @@ defmodule EventBus.Service.Subscription do
end

defp init_topic_map do
topics = TopicManager.all()

topics
|> Enum.map(fn topic -> {topic, []} end)
|> Enum.into(%{})
Enum.into(TopicManager.all(), %{}, fn topic -> {topic, []} end)
end
end

0 comments on commit 379cbf8

Please sign in to comment.