agemooij / riak-scala-client

An easy to use, non-blocking, fast Scala client library for interacting with Riak.
http://riak.scalapenos.com/
Apache License 2.0
84 stars 24 forks source link

Conditional Fetch requests support #39

Open ajantis opened 8 years ago

ajantis commented 8 years ago

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.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.5%) to 81.308% when pulling 11ac7d02f3519871b623c4fcb5b6a708eec37281 on ajantis:conditional-fetch-support into 54f742a19ab6a1bf5d40f7b4a5ef788e8d2e9138 on agemooij:master.

agemooij commented 8 years ago

Looks good! I made some minor comments but nothing really important. Feel free to merge at any time.

ajantis commented 8 years ago

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

agemooij commented 8 years ago

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 😄

ajantis commented 7 years ago

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.