Skip to content

Commit

Permalink
Add get_existing and update_existing ops to http driver for 404-sensi…
Browse files Browse the repository at this point in the history
…tivity.
  • Loading branch information
seancribbs committed Sep 23, 2010
1 parent 0308496 commit 0fec472
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/basho_bench_driver_http_raw.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ run(get, KeyGen, _ValueGen, State) ->
{error, Reason} ->
{error, Reason, S2}
end;
run(get_existing, KeyGen, _ValueGen, State) ->
{NextUrl, S2} = next_url(State),
case do_get(url(NextUrl, KeyGen, State#state.path_params)) of
{not_found, Url} ->
{error, {not_found, Url}, S2};
{ok, _Url, _Headers} ->
{ok, S2};
{error, Reason} ->
{error, Reason, S2}
end;
run(update, KeyGen, ValueGen, State) ->
{NextUrl, S2} = next_url(State),
case do_get(url(NextUrl, KeyGen, State#state.path_params)) of
Expand All @@ -101,6 +111,24 @@ run(update, KeyGen, ValueGen, State) ->
{error, Reason, S2}
end;

{ok, Url, Headers} ->
Vclock = lists:keyfind("X-Riak-Vclock", 1, Headers),
case do_put(Url, [State#state.client_id, Vclock], ValueGen) of
ok ->
{ok, S2};
{error, Reason} ->
{error, Reason, S2}
end
end;
run(update_existing, KeyGen, ValueGen, State) ->
{NextUrl, S2} = next_url(State),
case do_get(url(NextUrl, KeyGen, State#state.path_params)) of
{error, Reason} ->
{error, Reason, S2};

{not_found, Url} ->
{error, {not_found, Url}, S2};

{ok, Url, Headers} ->
Vclock = lists:keyfind("X-Riak-Vclock", 1, Headers),
case do_put(Url, [State#state.client_id, Vclock], ValueGen) of
Expand Down

0 comments on commit 0fec472

Please sign in to comment.