Skip to content
This repository has been archived by the owner on May 20, 2019. It is now read-only.

Commit

Permalink
Accept GenServer.server() type in Postgrex.Notifications API (elixir-…
Browse files Browse the repository at this point in the history
…ecto#357)

This fixes dialyzer warnings when using a named process for
Postgrex.Notifications.
  • Loading branch information
mbuhot authored and José Valim committed Jan 24, 2018
1 parent 6a75226 commit b41c695
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/postgrex/notifications.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ defmodule Postgrex.Notifications do

## PUBLIC API ##

@type server :: GenServer.server()

@doc """
Start the notification connection process and connect to postgres.
Expand All @@ -36,7 +38,7 @@ defmodule Postgrex.Notifications do
* `:timeout` - Call timeout (default: `#{@timeout}`)
"""
@spec listen(pid, String.t, Keyword.t) :: {:ok, reference}
@spec listen(server, String.t, Keyword.t) :: {:ok, reference}
def listen(pid, channel, opts \\ []) do
message = {:listen, channel}
timeout = opts[:timeout] || @timeout
Expand All @@ -46,7 +48,7 @@ defmodule Postgrex.Notifications do
@doc """
Listens to an asynchronous notification channel `channel`. See `listen/2`.
"""
@spec listen!(pid, String.t, Keyword.t) :: reference
@spec listen!(server, String.t, Keyword.t) :: reference
def listen!(pid, channel, opts \\ []) do
{:ok, ref} = listen(pid, channel, opts)
ref
Expand All @@ -60,7 +62,7 @@ defmodule Postgrex.Notifications do
* `:timeout` - Call timeout (default: `#{@timeout}`)
"""
@spec unlisten(pid, reference, Keyword.t) :: :ok
@spec unlisten(server, reference, Keyword.t) :: :ok
def unlisten(pid, ref, opts \\ []) do
message = {:unlisten, ref}
timeout = opts[:timeout] || @timeout
Expand All @@ -74,7 +76,7 @@ defmodule Postgrex.Notifications do
Stops listening on the given channel by passing the reference returned from
`listen/2`.
"""
@spec unlisten!(pid, reference, Keyword.t) :: :ok
@spec unlisten!(server, reference, Keyword.t) :: :ok
def unlisten!(pid, ref, opts \\ []) do
unlisten(pid, ref, opts)
end
Expand Down

0 comments on commit b41c695

Please sign in to comment.