-
Notifications
You must be signed in to change notification settings - Fork 125
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
Enhance Application.get_channel
and Application.get_connection
#212
Conversation
…sh if the process is not alive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! Only trivial comments. We can merge it once they are addressed. Thanks!
mix.exs
Outdated
@@ -2,7 +2,7 @@ defmodule AMQP.Mixfile do | |||
use Mix.Project | |||
|
|||
@source_url "https://github.com/pma/amqp" | |||
@version "3.1.0" | |||
@version "3.1.1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the versioning bump from PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
lib/amqp/application/connection.ex
Outdated
with false <- whereis(name) |> is_nil(), | ||
conn <- GenServer.call(get_server_name(name), :get_connection) do | ||
if conn |> is_nil(), do: {:error, :not_connected}, else: {:ok, conn} | ||
else | ||
true -> {:error, :connection_not_found} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with false <- whereis(name) |> is_nil(), | |
conn <- GenServer.call(get_server_name(name), :get_connection) do | |
if conn |> is_nil(), do: {:error, :not_connected}, else: {:ok, conn} | |
else | |
true -> {:error, :connection_not_found} | |
server_name = get_server_name(name) | |
with false <- server_name |> whereis() |> is_nil(), | |
conn = %{} <- GenServer.call(server_name, :get_connection)} do | |
{:ok, conn} | |
else | |
true -> {:error, :connection_not_found} | |
nil -> {:error, :not_connected} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whereis/1
function is already there in the module.:
def whereis(name) do
name
|> get_server_name()
|> GenServer.whereis()
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
Application.get_channel
andApplication.get_connection
no longer crash if the name of the process given is not alive.