Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

WHISTLE-1650: formatting and add the host/1 helper

  • Loading branch information...
commit c0893d4667c3abdd01b30230a2b79196c9c88bad 1 parent a0355f2
@jamesaimonetti jamesaimonetti authored
Showing with 22 additions and 19 deletions.
  1. +22 −19 lib/whistle_amqp-1.0.0/src/wh_amqp_broker.erl
View
41 lib/whistle_amqp-1.0.0/src/wh_amqp_broker.erl
@@ -10,12 +10,14 @@
-include("amqp_util.hrl").
--export([new/0]).
--export([name/1]).
--export([uri/1, set_uri/2]).
--export([use_federation/1, set_use_federation/2]).
--export([params/1]).
--export([is_available/1, set_is_available/2]).
+-export([new/0
+ ,name/1
+ ,host/1
+ ,uri/1, set_uri/2
+ ,use_federation/1, set_use_federation/2
+ ,params/1
+ ,is_available/1, set_is_available/2
+ ]).
-record(amqp_broker, {uri :: 'undefined' | string()
,params :: 'undefined' | #'amqp_params_direct'{} | #'amqp_params_network'{}
@@ -27,16 +29,13 @@
-export_type([broker/0]).
-spec new/0 :: () -> broker().
-new() ->
- #amqp_broker{}.
+new() -> #amqp_broker{}.
-spec name/1 :: (broker()) -> 'undefined' | atom().
-name(#amqp_broker{uri=URI}) ->
- wh_util:to_atom(URI, true).
+name(#amqp_broker{uri=URI}) -> wh_util:to_atom(URI, true).
-spec uri/1 :: (broker()) -> 'undefined' | string().
-uri(#amqp_broker{uri=URI}) ->
- URI.
+uri(#amqp_broker{uri=URI}) -> URI.
-spec set_uri/2 :: (atom() | string() | ne_binary(), broker()) -> broker().
set_uri(URI, Broker) ->
@@ -45,20 +44,24 @@ set_uri(URI, Broker) ->
Broker#amqp_broker{uri=U, params=Params}.
-spec use_federation/1 :: (broker()) -> boolean().
-use_federation(#amqp_broker{use_federation=UseFederation}) ->
- UseFederation.
+use_federation(#amqp_broker{use_federation=UseFederation}) -> UseFederation.
-spec set_use_federation/2 :: (atom() | string() | ne_binary(), broker()) -> broker().
set_use_federation(UseFederation, Broker) ->
Broker#amqp_broker{use_federation=wh_util:is_true(UseFederation)}.
-spec params/1 :: (broker()) -> 'undefined' | #'amqp_params_direct'{} | #'amqp_params_network'{}.
-params(#amqp_broker{params=Params}) ->
- Params.
-
+params(#amqp_broker{params=Params}) -> Params.
+
+-spec host/1 :: (broker() | #amqp_params_direct{} | #amqp_params_network{}) -> 'undefined' | ne_binary().
+host(#amqp_broker{} = Broker) -> host(params(Broker));
+host(#amqp_params_direct{node=undefined}) -> undefined;
+host(#amqp_params_direct{node=H}) -> wh_util:to_binary(H);
+host(#amqp_params_network{host=undefined}) -> undefined;
+host(#amqp_params_network{host=H}) -> wh_util:to_binary(H).
+
-spec is_available/1 :: (broker()) -> boolean().
-is_available(#amqp_broker{is_available=IsAvailable}) ->
- IsAvailable.
+is_available(#amqp_broker{is_available=IsAvailable}) -> IsAvailable.
-spec set_is_available/2 :: (atom() | string() | ne_binary(), broker()) -> broker().
set_is_available(IsAvailable, Broker) ->
Please sign in to comment.
Something went wrong with that request. Please try again.