Skip to content

Commit

Permalink
Mas i1847 putapi (#1848)
Browse files Browse the repository at this point in the history
* Never GET before PUT

As the if_not_modified and if_none_match are not supported via the HTTP API for non-consistent PUT - simply build object from a new object, as with PB API.

* More webmachine friendly override

resource_exists/2 is a key part of the flow for both GET and PUT, as conditional HTTP headers require this check for PUTs.  therefore only override resource_exists (and don't fetch) when it is a PUT, and those conditional headers do not exist.

* Attempt to tidy and refactor delete

So that delete does not require a fetch

* Pipe-cleaned delete path

* Add if_not_modified conflict check

To mimic if_not_modified feature via PB API

* Use hyphen not underscore

To be consistent with other HTTP headers

* Revert to 404 on if DELETE not_found

Also ensure the timeouts passed in in a delete is respected, and passed through the riak_client to the FSM.
  • Loading branch information
martinsumner committed Feb 1, 2023
1 parent aff880e commit b76e327
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 121 deletions.
4 changes: 2 additions & 2 deletions src/riak_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ delete(Bucket,Key,{?MODULE, [_Node, _ClientId]}=THIS) -> delete(Bucket,Key,[],?D
%% nodes have responded with a value or error.
%% @equiv delete(Bucket, Key, RW, default_timeout())
delete(Bucket,Key,Options,{?MODULE, [_Node, _ClientId]}=THIS) when is_list(Options) ->
delete(Bucket,Key,Options,?DEFAULT_TIMEOUT,THIS);
delete(Bucket,Key,Options,recv_timeout(Options),THIS);
delete(Bucket,Key,RW,{?MODULE, [_Node, _ClientId]}=THIS) ->
delete(Bucket,Key,[{rw, RW}],?DEFAULT_TIMEOUT,THIS).

Expand Down Expand Up @@ -622,7 +622,7 @@ delete_vclock(Bucket,Key,VClock,{?MODULE, [_Node, _ClientId]}=THIS) ->
%% nodes have responded with a value or error.
%% @equiv delete(Bucket, Key, RW, default_timeout())
delete_vclock(Bucket,Key,VClock,Options,{?MODULE, [_Node, _ClientId]}=THIS) when is_list(Options) ->
delete_vclock(Bucket,Key,VClock,Options,?DEFAULT_TIMEOUT,THIS);
delete_vclock(Bucket,Key,VClock,Options,recv_timeout(Options),THIS);
delete_vclock(Bucket,Key,VClock,RW,{?MODULE, [_Node, _ClientId]}=THIS) ->
delete_vclock(Bucket,Key,VClock,[{rw, RW}],?DEFAULT_TIMEOUT,THIS).

Expand Down
3 changes: 2 additions & 1 deletion src/riak_kv_get_fsm.erl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
-module(riak_kv_get_fsm).
-behaviour(gen_fsm).
-include_lib("riak_kv_vnode.hrl").
-include_lib("kernel/include/logger.hrl").
-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-export([test_link/7, test_link/5]).
Expand Down Expand Up @@ -704,7 +705,7 @@ read_repair(GetCoreIndices, RepairObj,
fun({{Idx, Node}, _Type, Reason}) ->
case app_helper:get_env(riak_kv, read_repair_log, false) of
true ->
lager:info(
?LOG_INFO(
"Read repair of ~p on ~w ~w for reason ~w",
[BKey, Idx, Node, Reason]);
false ->
Expand Down
Loading

0 comments on commit b76e327

Please sign in to comment.