Commits

Anonymous committed fa91687

support symbolic values in PBC client (closes #277)

Comments (0)

Files changed (1)

apps/riak_kv/src/riak_kv_pb_socket.erl

                                  server_version = get_riak_version()},
     send_msg(Resp, State);
 
-process_message(#rpbgetreq{bucket=B, key=K, r=R}, 
+process_message(#rpbgetreq{bucket=B, key=K, r=R0}, 
                 #state{client=C} = State) ->
+    R = case R0 of 
+        ?RIAKC_RW_ONE -> one;
+        ?RIAKC_RW_QUORUM -> quorum;
+        ?RIAKC_RW_ALL -> all;
+        Other  -> Other
+        end,
     case C:get(B, K, default_r(R)) of
         {ok, O} ->
             PbContent = riakc_pb:pbify_rpbcontents(riak_object:get_contents(O), []),
     end;
 
 process_message(#rpbputreq{bucket=B, key=K, vclock=PbVC, content=RpbContent,
-                           w=W, dw=DW, return_body=ReturnBody}, 
+                           w=W0, dw=DW0, return_body=ReturnBody}, 
                 #state{client=C} = State) ->
 
     O0 = riak_object:new(B, K, <<>>),  
     O1 = update_rpbcontent(O0, RpbContent),
     O  = update_pbvc(O1, PbVC),
     % erlang_protobuffs encodes as 1/0/undefined
+    W = case W0 of
+            ?RIAKC_RW_ONE -> one;
+            ?RIAKC_RW_ALL -> all;
+            ?RIAKC_RW_QUORUM -> quorum;
+            Other  -> Other
+        end,
+    DW = case DW0 of
+            ?RIAKC_RW_ONE -> one;
+            ?RIAKC_RW_ALL -> all;
+            ?RIAKC_RW_QUORUM -> quorum;
+            Other1 -> Other1
+        end,
     Options = case ReturnBody of 1 -> [returnbody]; _ -> [] end,
     case C:put(O, default_w(W), default_dw(DW), default_timeout(), Options) of
         ok ->
             send_error("~p", [Reason], State)
     end;
 
-process_message(#rpbdelreq{bucket=B, key=K, rw=RW}, 
+process_message(#rpbdelreq{bucket=B, key=K, rw=RW0}, 
                 #state{client=C} = State) ->
+    RW = case RW0 of 
+        ?RIAKC_RW_ONE -> one;
+        ?RIAKC_RW_QUORUM -> quorum;
+        ?RIAKC_RW_ALL -> all;
+        Other -> Other
+        end,    
     case C:delete(B, K, default_rw(RW)) of
         ok ->
             send_msg(rpbdelresp, State);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.