~ubuntu-branches/ubuntu/trusty/rabbitmq-server/trusty

« back to all changes in this revision

Viewing changes to plugins-src/rabbitmq-shovel/src/rabbit_shovel_sup.erl

  • Committer: Package Import Robot
  • Author(s): Emile Joubert
  • Date: 2013-05-28 11:15:13 UTC
  • mfrom: (0.5.3) (0.1.38 sid)
  • Revision ID: package-import@ubuntu.com-20130528111513-5j5kgypgx9mmwzse
Tags: 3.1.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
-export([start_link/0, init/1]).
21
21
 
 
22
-import(rabbit_shovel_config, [ensure_defaults/2]).
 
23
 
22
24
-include("rabbit_shovel.hrl").
23
25
 
24
26
start_link() ->
63
65
  when is_atom(ShovelName) andalso is_list(ShovelConfig) ->
64
66
    case dict:is_key(ShovelName, Acc) of
65
67
        true  -> {error, {duplicate_shovel_definition, ShovelName}};
66
 
        false -> case rabbit_shovel_config:parse(ShovelName, ShovelConfig) of
67
 
                     {ok, _Shovel} ->
68
 
                         Acc2 = dict:store(ShovelName, ShovelConfig, Acc),
 
68
        false -> case validate_shovel_config(ShovelName, ShovelConfig) of
 
69
                     {ok, Shovel} ->
 
70
                         %% make sure the config we accumulate has any
 
71
                         %% relevant default values (discovered during
 
72
                         %% validation), applied back to it
 
73
                         UpdatedConfig = ensure_defaults(ShovelConfig, Shovel),
 
74
                         Acc2 = dict:store(ShovelName, UpdatedConfig, Acc),
69
75
                         parse_configuration(Defaults, Env, Acc2);
70
76
                     Error ->
71
77
                         Error
73
79
    end;
74
80
parse_configuration(_Defaults, _, _Acc) ->
75
81
    {error, require_list_of_shovel_configurations}.
 
82
 
 
83
validate_shovel_config(ShovelName, ShovelConfig) ->
 
84
    rabbit_shovel_config:parse(ShovelName, ShovelConfig).