-
Notifications
You must be signed in to change notification settings - Fork 24
Conditional Fetch requests support #39
base: master
Are you sure you want to change the base?
Conversation
…nd If-(Not)-Modified HTTP headers support in Riak
…ngle values from Riak
…g with If-Match condition that doesn't hold
…or any time in future
As IfNoneChange accepts only one ETag value it's probably better to adjust it's name accordingly
…cause test flickiness)
… parameters together
import spray.http.Uri | ||
import spray.http.Uri._ | ||
private[riak] trait RiakHttpSupport { | ||
import spray.http.{ Uri, HttpHeader, HttpHeaders, EntityTag }, HttpHeaders._, Uri._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer consistent wildcard imports instead of explicit imports but that's a personal thing and I'm not religious about it.
Looks good! |
// TODO: case NotModified => successful(None) | ||
case OK ⇒ successful(toRiakValue(response)) | ||
case NotFound ⇒ successful(None) | ||
case NotModified ⇒ successful(None) // This means that client is not able to distinguish cases when value is not in Riak or a supplied condition is not met. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a way to distinguish between the not-found and not-modified case? Perhaps in a different method to retain backwards compatibility.
Hey Age, Thanks for your swift review! ;) 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, |
I agree with @didierliauw too. I recommend using Spray's |
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. |
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.