Open ajantis opened 8 years ago
Looks good! I made some minor comments but nothing really important. Feel free to merge at any time.
Hey Age,
Thanks for your swift review! ;) I am applying the comments.
Didier's remark makes sense, too: I also was thinking that it might be needed for a client to be able to distinguish 'Not Found' and 'Found but Precondition Failed' cases.
BR, Dmitry
I agree with @didierliauw too.
I recommend using Spray's StatusCodes
(or akka-http's StatusCodes
) as inspiration since Http doesn't have 404 and 304 for nothing 😄
I put this change on hold for now, as there is one substantial piece missing. In case of siblings, all ETag-based conditions don't work with resolved RiakValue's ETag, only with the parent ETag. Currently, library doesn't expose those parent ETags anyhow, so this needs to be fixed as part of this PR, I guess.
Overview
Introduces support for conditional request parameters when fetching a value from Riak bucket.
Riak Fetch Object (HTTP API) parameters are described in here: http://docs.basho.com/riak/kv/2.1.4/developing/api/http/fetch-object/#request
Supported conditions:
Conditions can be combined together.
Compatibility
This change is backwards compatible with existing code that uses the library.
Tests
Tested with integration specs (RiakBucketSpec.scala) against Riak 1.4 (1.4.10) and Riak 2 (2.1.1).
Future improvements
Conditional parameters support can be expanded also to Store Object API: http://docs.basho.com/riak/kv/2.1.4/developing/api/http/store-object/#request
It works the same way in Riak.
Support of other API backends
Note that the conditional requests support in Protobuf API is a bit different: http://docs.basho.com/riak/kv/2.1.4/developing/api/protocol-buffers/fetch-object/#request
So HTTP API and Protobuf API are not on par in that sense.