diff --git a/lib/gnat.ex b/lib/gnat.ex index aeb9263..00c5d8f 100644 --- a/lib/gnat.ex +++ b/lib/gnat.ex @@ -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() } @@ -102,6 +103,7 @@ defmodule Gnat do connection_timeout: 3_000, ssl_opts: [], tls: false, + verbose: false, inbox_prefix: "_INBOX.", } @@ -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, diff --git a/lib/gnat/handshake.ex b/lib/gnat/handshake.ex index a6e7b1f..59e0c60 100644 --- a/lib/gnat/handshake.ex +++ b/lib/gnat/handshake.ex @@ -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 diff --git a/test/gnat_test.exs b/test/gnat_test.exs index d45c3f5..97853be 100644 --- a/test/gnat_test.exs +++ b/test/gnat_test.exs @@ -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 diff --git a/test/test_helper.exs b/test/test_helper.exs index 7df5502..72e7c35 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -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]) defmodule RpcEndpoint do def init do