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

Support OK message and verbose mode #134

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions lib/gnat.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ defmodule Gnat do
optional(:port) => non_neg_integer(),
optional(:ssl_opts) => list(),
optional(:tcp_opts) => list(),
optional(:verbose) => boolean(),
optional(:tls) => boolean()
}

Expand Down Expand Up @@ -102,6 +103,7 @@ defmodule Gnat do
connection_timeout: 3_000,
ssl_opts: [],
tls: false,
verbose: false,
inbox_prefix: "_INBOX.",
}

Expand Down Expand Up @@ -555,6 +557,9 @@ defmodule Gnat do
send state.pinger, :pong
state
end
defp process_message(:ok, state) do
state
end
defp process_message({:error, message}, state) do
:error_logger.error_report([
type: :gnat_error_from_broker,
Expand Down
2 changes: 1 addition & 1 deletion lib/gnat/handshake.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule Gnat.Handshake do
end

def negotiate_settings(server_settings, user_settings) do
%{verbose: false}
%{verbose: Map.get(user_settings, :verbose, false)}
|> negotiate_auth(server_settings, user_settings)
|> negotiate_headers(server_settings, user_settings)
end
Expand Down
6 changes: 6 additions & 0 deletions test/gnat_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ defmodule GnatTest do
:ok = Gnat.stop(pid)
end

test "connect to a server using verbose mode" do
{:ok, pid} = Gnat.start_link(%{verbose: true})
assert Process.alive?(pid)
:ok = Gnat.stop(pid)
end

# We have to skip this test in CI builds because CircleCI doesn't enable IPv6 in it's docker
# configuration. See https://circleci.com/docs/faq#can-i-use-ipv6-in-my-tests
@tag :ci_skip
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ case :gen_tcp.connect('localhost', 4222, [:binary]) do
end

# this is used by some property tests, see test/gnat_property_test.exs
Gnat.start_link(%{}, [name: :test_connection])
Gnat.start_link(%{verbose: true}, [name: :test_connection])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we want this connection to run in verbose mode? I would think that because we are using this test for some property tests, we would want it to have minimal overhead?


defmodule RpcEndpoint do
def init do
Expand Down