anchor.diff:  
   do_resolve([Target|Rest], Config, Pid, Fun, Specs, Weights) ->
       Pool = maps:get(pool, Target, 1),
  +    Max = maps:get(max_exclusive, Target, Pool),
       {ConnList, Meta} = case Fun(Target, Config, Pid) of
           {ok, ConnList0, Meta0} ->
               {ConnList0, Meta0};
  
positive.code: 
  
  %% @private
  do_get_pid([Pid]) ->
      Pid;
  do_get_pid(Pids) ->
      lists:nth(rand:uniform(length(Pids)), Pids).
  
  
  %% @private
  do_get_exclusive_pid(Pids, {true, UserPid}, State) ->
      #state{conn_pids=ConnPids, conn_user_mons=Mons} = State,
      Pids2 = lists:filter(
          fun(Pid) ->
              case maps:get(Pid, ConnPids) of
                  {_ConnId, undefined} -> true;
                  {_ConnId, _OldRef} -> false
              end
          end,
          Pids),
      case Pids2 of
          [] ->
              false;
          _ ->
              Pid = do_get_pid(Pids2),
              {ConnId, undefined} = maps:get(Pid, ConnPids),
              Mon = monitor(process, UserPid),
              State2 = State#state{
                  conn_pids = ConnPids#{Pid => {ConnId, Mon}},
                  conn_user_mons = Mons#{Mon => Pid}
              },
              {ok, Pid, State2}
      end.
  
  
  %% @private
  
negative.code:     Pos = rand:uniform(Max),
      ConnId = do_find_conn(Pos, Weights),
      Spec = maps:get(ConnId, ConnSpec),
      #conn_spec{id=ConnId, pool=Pool, max_exclusive=Max, meta=Meta} = Spec,
      ?DEBUG("selected weight ~p: ~p", [Pos, ConnId], State),
      case maps:find(ConnId, ConnStatus) of
          {ok, #conn_status{status=active, conn_pids=Pids}} ->
              ActivePids = length(Pids),
              case ActivePids < Pool of
                  true ->
                      % Slots still available
                      connect(Spec, Tries, From, Exclusive, State);
                  false when Exclusive==false ->
                      ?DEBUG("selecting existing pid ~p: ~p", [Pos, ConnId], State),
                      Pid = do_get_random_pid(Pids),
                      gen_server:reply(From, {ok, Pid, Meta#{conn_id=>ConnId}}),
                      State;
                  false ->
                      % We reached all possible connections
                      case find_conn_pid_exclusive(Pids, Exclusive, State) of
                          {ok, Pid, ConnId, State2} ->
                              ?DEBUG("selecting and locking existing pid: ~p", [ConnId], State2),
                              gen_server:reply(From, {ok, Pid, Meta#{conn_id=>ConnId}}),
                              State2;
                          {error, no_free_connections} ->
                              case ActivePids < Max of
                                  true ->
                                      connect(Spec, Tries, From, Exclusive, State);
                                  false ->
                                      ?DEBUG("max connections reached", [], State),
                                      gen_server:reply(From, {error, max_connections_reached}),
                                      State
                              end
                      end
              end;
          _ ->
              % If inactive or not yet created
              connect(Spec, Tries, From, Exclusive, State)
      end.
  
  
  %% @private
  find_conn_pid_exclusive(Pids, {true, UserPid}, State) ->
      #state{
          conn_pids= ConnPids,
          conn_user_mons = Mons
      } = State,
      Pids2 = lists:filter(
          fun(Pid) ->
              case maps:get(Pid, ConnPids) of
                  {_ConnId, undefined} -> true;
                  {_ConnId, _OldRef} -> false
              end
          end,
          Pids),
      case Pids2 of
          [] ->
              {error, no_free_connections};
          _ ->
              Pid = do_get_random_pid(Pids2),
              {ConnId, undefined} = maps:get(Pid, ConnPids),
              Mon = monitor(process, UserPid),
              State2 = State#state{
                  conn_pids = ConnPids#{Pid => {ConnId, Mon}},
                  conn_user_mons = Mons#{Mon => Pid}
              },
              {ok, Pid, ConnId, State2}
      end.
  
  
  