Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Az419 update delete interface #30

Merged
merged 3 commits into from Jun 8, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 47 additions & 8 deletions src/riakc_pb_socket.erl
Expand Up @@ -285,12 +285,22 @@ delete(Pid, Bucket, Key, Timeout) when is_integer(Timeout); Timeout =:= infinity
delete(Pid, Bucket, Key, [], Timeout);

%% @doc Delete the key/value with options
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
delete(Pid, Bucket, Key, Options) ->
delete(Pid, Bucket, Key, Options, default_timeout(delete_timeout)).

%% @doc Delete the key/value with options and timeout
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
-spec delete(pid(), bucket() | string(), key() | string(),
riak_pbc_options(), timeout()) -> ok | {error, term()}.
delete(Pid, Bucket, Key, Options, Timeout) ->
Expand All @@ -309,12 +319,22 @@ delete_vclock(Pid, Bucket, Key, VClock, Timeout) when is_integer(Timeout); Timeo
delete_vclock(Pid, Bucket, Key, VClock, [], Timeout);

%% @doc Delete the key/value with options
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
delete_vclock(Pid, Bucket, Key, VClock, Options) ->
delete_vclock(Pid, Bucket, Key, VClock, Options, default_timeout(delete_timeout)).

%% @doc Delete the key/value with options and timeout
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
-spec delete_vclock(pid(), bucket() | string(), key() | string(), vclock:vclock(),
riak_pbc_options(), timeout()) -> ok | {error, term()}.
delete_vclock(Pid, Bucket, Key, VClock, Options, Timeout) ->
Expand All @@ -324,21 +344,30 @@ delete_vclock(Pid, Bucket, Key, VClock, Options, Timeout) ->


%% @doc Delete the riak object
%% [{rw,2}] sets rw=2
-spec delete_obj(pid(), riakc_obj()) -> ok | {error, term()}.
delete_obj(Pid, Obj) ->
delete_vclock(Pid, riakc_obj:bucket(Obj), riakc_obj:key(Obj),
riakc_obj:vclock(Obj), [], default_timeout(delete_timeout)).

%% @doc Delete the riak object with options
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
-spec delete_obj(pid(), riakc_obj(), riak_pbc_options()) -> ok | {error, term()}.
delete_obj(Pid, Obj, Options) ->
delete_vclock(Pid, riakc_obj:bucket(Obj), riakc_obj:key(Obj),
riakc_obj:vclock(Obj), Options, default_timeout(delete_timeout)).

%% @doc Delete the riak object with options and timeout
%% [{rw,2}] sets rw=2
%% [{rw,2}] sets rw=2 - this is deprecated
%% [{r,1}] sets r=1
%% [{w,all}] sets w=all
%% [{pr,quorum}] sets pr=quorum
%% [{pw,2}] sets pw=2
%% [{dw,2}] sets dw=2
-spec delete_obj(pid(), riakc_obj(), riak_pbc_options(), timeout()) -> ok | {error, term()}.
delete_obj(Pid, Obj, Options, Timeout) ->
delete_vclock(Pid, riakc_obj:bucket(Obj), riakc_obj:key(Obj),
Expand Down Expand Up @@ -870,7 +899,17 @@ put_options([if_none_match | Rest], Req) ->
delete_options([], Req) ->
Req;
delete_options([{rw, RW} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{rw = normalize_rw_value(RW)}).
delete_options(Rest, Req#rpbdelreq{rw = normalize_rw_value(RW)});
delete_options([{r, R} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{r = normalize_rw_value(R)});
delete_options([{w, W} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{w = normalize_rw_value(W)});
delete_options([{pr, PR} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{pr = normalize_rw_value(PR)});
delete_options([{pw, PW} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{pw = normalize_rw_value(PW)});
delete_options([{dw, DW} | Rest], Req) ->
delete_options(Rest, Req#rpbdelreq{dw = normalize_rw_value(DW)}).

normalize_rw_value(one) -> ?RIAKC_RW_ONE;
normalize_rw_value(quorum) -> ?RIAKC_RW_QUORUM;
Expand Down
5 changes: 5 additions & 0 deletions src/riakclient.proto
Expand Up @@ -166,6 +166,11 @@ message RpbDelReq {
required bytes key = 2;
optional uint32 rw = 3;
optional bytes vclock = 4;
optional uint32 r = 5;
optional uint32 w = 6;
optional uint32 pr = 7;
optional uint32 pw = 8;
optional uint32 dw = 9;
}

// Delete response - not defined, will return a RpbDelResp on success or RpbErrorResp on failure
Expand Down