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 authored Feb 1, 2023
1 parent fbb5363 commit 9c138dc
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 121 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
{riak_api, {git, "https://github.com/basho/riak_api.git", {branch, "develop-3.0"}}},
{hyper, {git, "https://github.com/basho/hyper", {tag, "1.1.0"}}},
{kv_index_tictactree, {git, "https://github.com/martinsumner/kv_index_tictactree.git", {branch, "develop-3.0"}}},
{riakhttpc, {git, "https://github.com/basho/riak-erlang-http-client", {tag, "3.0.10"}}}
{riakhttpc, {git, "https://github.com/basho/riak-erlang-http-client", {branch, "develop-3.0"}}}
]}.
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
Loading

0 comments on commit 9c138dc

Please sign in to comment.