~ubuntu-branches/ubuntu/saucy/rabbitmq-server/saucy-proposed

« back to all changes in this revision

Viewing changes to plugins-src/rabbitmq-old-federation/src/rabbit_federation_old_link_sup.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2013-05-02 11:19:31 UTC
  • mfrom: (0.5.2) (0.1.37 sid)
  • Revision ID: package-import@ubuntu.com-20130502111931-xnoj0sejto2tewcj
Tags: 3.1.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% The contents of this file are subject to the Mozilla Public License
2
 
%% Version 1.1 (the "License"); you may not use this file except in
3
 
%% compliance with the License. You may obtain a copy of the License
4
 
%% at http://www.mozilla.org/MPL/
5
 
%%
6
 
%% Software distributed under the License is distributed on an "AS IS"
7
 
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8
 
%% the License for the specific language governing rights and
9
 
%% limitations under the License.
10
 
%%
11
 
%% The Original Code is RabbitMQ Federation.
12
 
%%
13
 
%% The Initial Developer of the Original Code is VMware, Inc.
14
 
%% Copyright (c) 2007-2013 VMware, Inc.  All rights reserved.
15
 
%%
16
 
 
17
 
-module(rabbit_federation_old_link_sup).
18
 
 
19
 
-behaviour(supervisor2).
20
 
 
21
 
-include_lib("rabbit_common/include/rabbit.hrl").
22
 
-include("rabbit_federation_old.hrl").
23
 
 
24
 
%% Supervises the upstream links for an exchange.
25
 
 
26
 
-export([start_link/1]).
27
 
-export([init/1]).
28
 
 
29
 
start_link(Args) -> supervisor2:start_link(?MODULE, Args).
30
 
 
31
 
%%----------------------------------------------------------------------------
32
 
 
33
 
init({UpstreamSet, XName}) ->
34
 
    %% We can't look this up in fed_exchange or fed_sup since
35
 
    %% mirrored_sup may fail us over to a different node with a
36
 
    %% different definition of the same upstream-set. This is the
37
 
    %% first point at which we know we're not switching nodes.
38
 
    {ok, Upstreams} = rabbit_federation_old_upstream:from_set(UpstreamSet, XName),
39
 
    %% 1, 1 so that the supervisor can give up and get into waiting
40
 
    %% for the reconnect_delay quickly.
41
 
    {ok, {{one_for_one, 1, 1},
42
 
          [spec(Upstream, XName) || Upstream <- Upstreams]}}.
43
 
 
44
 
spec(Upstream = #upstream{reconnect_delay = Delay}, XName) ->
45
 
    {Upstream, {rabbit_federation_old_link, start_link, [{Upstream, XName}]},
46
 
     {permanent, Delay}, ?MAX_WAIT, worker,
47
 
     [rabbit_federation_old_link]}.