Skip to content
This repository has been archived by the owner on Nov 18, 2020. It is now read-only.

Commit

Permalink
Merge bug25538 into stable (second time, unpick of bug 25677
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon MacMullen committed Aug 5, 2013
2 parents ff7f69f + 54cc5e1 commit 3bf3a2d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/amqp_auth_mechanisms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

-include("amqp_client.hrl").

-export([plain/3, amqplain/3, external/3]).
-export([plain/3, amqplain/3, external/3, crdemo/3]).

%%---------------------------------------------------------------------------

Expand All @@ -41,3 +41,11 @@ external(none, _, init) ->
{<<"EXTERNAL">>, []};
external(none, _, _State) ->
{<<"">>, _State}.

crdemo(none, _, init) ->
{<<"RABBIT-CR-DEMO">>, 0};
crdemo(none, #amqp_params_network{username = Username}, 0) ->
{Username, 1};
crdemo(<<"Please tell me your password">>,
#amqp_params_network{password = Password}, 1) ->
{<<"My password is ", Password/binary>>, 2}.
2 changes: 2 additions & 0 deletions src/amqp_network_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ handshake_recv(Expecting) ->
case {Expecting, element(1, Method)} of
{E, M} when E =:= M ->
Method;
{'connection.tune', 'connection.secure'} ->
Method;
{'connection.open_ok', _} ->
{closing,
#amqp_error{name = command_invalid,
Expand Down
14 changes: 13 additions & 1 deletion src/amqp_rpc_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

-behaviour(gen_server).

-export([start/2, stop/1]).
-export([start/2, start_link/2, stop/1]).
-export([call/2]).
-export([init/1, terminate/2, code_change/3, handle_call/3,
handle_cast/2, handle_info/2]).
Expand Down Expand Up @@ -53,6 +53,18 @@ start(Connection, Queue) ->
{ok, Pid} = gen_server:start(?MODULE, [Connection, Queue], []),
Pid.

%% @spec (Connection, Queue) -> RpcClient
%% where
%% Connection = pid()
%% Queue = binary()
%% RpcClient = pid()
%% @doc Starts, and links to, a new RPC client instance that sends requests
%% to a specified queue. This function returns the pid of the RPC client
%% process that can be used to invoke RPCs and stop the client.
start_link(Connection, Queue) ->
{ok, Pid} = gen_server:start_link(?MODULE, [Connection, Queue], []),
Pid.

%% @spec (RpcClient) -> ok
%% where
%% RpcClient = pid()
Expand Down
16 changes: 15 additions & 1 deletion src/amqp_rpc_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

-export([init/1, terminate/2, code_change/3, handle_call/3,
handle_cast/2, handle_info/2]).
-export([start/3]).
-export([start/3, start_link/3]).
-export([stop/1]).

-record(state, {channel,
Expand All @@ -51,6 +51,20 @@ start(Connection, Queue, Fun) ->
{ok, Pid} = gen_server:start(?MODULE, [Connection, Queue, Fun], []),
Pid.

%% @spec (Connection, Queue, RpcHandler) -> RpcServer
%% where
%% Connection = pid()
%% Queue = binary()
%% RpcHandler = function()
%% RpcServer = pid()
%% @doc Starts, and links to, a new RPC server instance that receives
%% requests via a specified queue and dispatches them to a specified
%% handler function. This function returns the pid of the RPC server that
%% can be used to stop the server.
start_link(Connection, Queue, Fun) ->
{ok, Pid} = gen_server:start_link(?MODULE, [Connection, Queue, Fun], []),
Pid.

%% @spec (RpcServer) -> ok
%% where
%% RpcServer = pid()
Expand Down

0 comments on commit 3bf3a2d

Please sign in to comment.