summaryrefslogtreecommitdiff
path: root/src/fabric_open.erl
blob: cab10c5d0f9048c5a1d4b8eb42b6bd817954cb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-module(fabric_open).

-export([open_doc/4]).

-include("../../couch/src/couch_db.hrl").


% open_db(<<"S", ShardFileName/binary>> = Name, Options) ->
%     case couch_db:open(ShardFileName, Options) of
%     {ok, Db} ->
%         {ok, Db#db{name = Name}};
%     {not_found, no_db_file} ->
%         {not_found, no_db_file}
%     end;
%
% open_db(DbName, Options) ->
%     Part = case lists:keyfind(node(), 1, membership2:all_nodes_parts(false)) of
%     {_, P} -> P;
%     _ -> throw({node_has_no_parts, node()})
%     end,
%     ShardName = partitions:shard_name(Part, DbName),
%     open_db(<<"S", ShardName/binary>>, Options).


open_doc(DbName, DocId, _Revs, _Options) ->
    NPs = partitions:key_nodes_parts(DbName, DocId),
    ?debugFmt("~nNPs: ~p~n", [NPs]),
    {ok, #doc{}}.





% open_doc(Db, DocId, Revs, Options) ->
%     {R,N} = get_quorum_constants(r, Options),
%     case cluster_ops:key_lookup(DocId, {dynomite_couch_api, get,
%             [Db, DocId, Revs, Options]}, r, R, N) of
%     {ok, [Doc|_Rest]} ->
%         {ok, Doc};
%     {ok, {not_found, Reason}, _Reasons} ->
%         {not_found, Reason};
%     [{error, Error}, {good, Good}, {bad, Bad}] ->
%         showroom_quorum_utils:handle_error(Error, Good, Bad);
%     Other ->
%         ?LOG_DEBUG("~nopen_doc Other: ~p~n", [Other]),
%         throw(Other)
%     end.