You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/12/03 20:34:13 UTC
[GitHub] davisp commented on a change in pull request #1789: New Feature:
Database Partitions
davisp commented on a change in pull request #1789: New Feature: Database Partitions
URL: https://github.com/apache/couchdb/pull/1789#discussion_r238426604
##########
File path: src/chttpd/src/chttpd_db.erl
##########
@@ -253,6 +255,41 @@ handle_view_cleanup_req(Req, Db) ->
ok = fabric:cleanup_index_files_all_nodes(Db),
send_json(Req, 202, {[{ok, true}]}).
+
+handle_partition_req(#httpd{method='GET', path_parts=[_,_,PartId]}=Req, Db) ->
+ couch_partition:validate_partition(PartId),
+ case couch_db:is_partitioned(Db) of
+ true ->
+ {ok, PartitionInfo} = fabric:get_partition_info(Db, PartId),
+ send_json(Req, {PartitionInfo});
+ false ->
+ throw({bad_request, <<"database is not partitioned">>})
+ end;
+
+handle_partition_req(#httpd{path_parts = [_, _, _]}=Req, _Db) ->
+ send_method_not_allowed(Req, "GET");
+
+handle_partition_req(#httpd{path_parts=[DbName, _, PartId | Rest]}=Req, Db) ->
+ case couch_db:is_partitioned(Db) of
+ true ->
+ QS = chttpd:qs(Req),
+ NewQS = lists:ukeysort(1, [{"partition", ?b2l(PartId)} | QS]),
+ NewReq = Req#httpd{
+ path_parts = [DbName | Rest],
+ qs = NewQS
+ },
+ case Rest of
+ [] ->
+ do_db_req(NewReq, Db);
Review comment:
That's actually dead code. `Rest == []` will have been caught by the first function clause. Must've from before the refactor. Will tidy this up.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services