anchor.diff:      %% server just returned the rpbdelresp code - no message was encoded
       {reply, ok, State};
   
  -process_response(#request{msg = rpblistbucketsreq},
  -                 #rpblistbucketsresp{buckets = Buckets}, State) ->
  -    {reply, {ok, Buckets}, State};
  -
  -process_response(#request{msg = rpblistbucketsreq},
  -                 rpblistbucketsresp, State) ->
  -    %% empty buckets generate an empty message
  -    {reply, {ok, []}, State};
  +process_response(#request{msg = #rpblistbucketsreq{}}=Request,
  +                 #rpblistbucketsresp{done = Done, buckets = Buckets}, 
  +                 State) ->
  +    _ = case Buckets of
  +            undefined ->
  +                ok;
  +            _ ->
  +                %% Have to directly use send_caller as may want to reply with done below.
  +                send_caller({buckets, Buckets}, Request)
  +        end,
  +    case Done of
  +        true ->
  +            {reply, done, State};
  +        1 ->
  +            {reply, done, State};
  +        _ ->
  +            {pending, State}
  +    end;
   
   process_response(#request{msg = #rpblistkeysreq{}}=Request,
                    #rpblistkeysresp{done = Done, keys = Keys}, State) ->
  
positive.code: %% Called after sending a message - supports returning a
  %% request id for streaming calls
  %% @private
  after_send(#request{msg = #rpblistkeysreq{}, ctx = {ReqId, _Client}}, State) ->
      {reply, {ok, ReqId}, State};
  after_send(#request{msg = #rpbmapredreq{}, ctx = {ReqId, _Client}}, State) ->
  
negative.code: mk_reqid() -> erlang:phash2(erlang:now()). % only has to be unique per-pid
  
  %% @private
  wait_for_list(ReqId) ->
      wait_for_list(ReqId, []).
  %% @private
  wait_for_list(ReqId, Acc) ->
      receive
          {ReqId, done} -> {ok, lists:flatten(Acc)};
          {ReqId, {error, Reason}} -> {error, Reason};
          {ReqId, {_, Res}} -> wait_for_list(ReqId, [Res|Acc])
      end.
  
  
  