diff options
author | Brad Anderson <brad@cloudant.com> | 2010-05-27 17:09:19 -0400 |
---|---|---|
committer | Brad Anderson <brad@cloudant.com> | 2010-05-27 17:09:19 -0400 |
commit | 6c7e3665cd941083dedb8ead5e9314f3c531ff89 (patch) | |
tree | 98e34ad5faf353bcce1ed600e511ef57ef09ee7f | |
parent | faedecbc0393d87523fbc19b9edc17504c504782 (diff) |
remove fabric_api, clean up other things to get futon rendering db list
-rw-r--r-- | ebin/fabric.app | 1 | ||||
-rw-r--r-- | src/fabric.erl | 31 | ||||
-rw-r--r-- | src/fabric_api.erl | 118 | ||||
-rw-r--r-- | src/fabric_doc.erl | 2 | ||||
-rw-r--r-- | src/fabric_util.erl | 2 |
5 files changed, 32 insertions, 122 deletions
diff --git a/ebin/fabric.app b/ebin/fabric.app index 60f1f634..e08f560b 100644 --- a/ebin/fabric.app +++ b/ebin/fabric.app @@ -5,7 +5,6 @@ {vsn, "0.1.0"}, {modules, [ fabric, - fabric_api, fabric_db, fabric_doc, fabric_rpc, diff --git a/src/fabric.erl b/src/fabric.erl index e75e31eb..0957387e 100644 --- a/src/fabric.erl +++ b/src/fabric.erl @@ -1,10 +1,18 @@ -module(fabric). -export([all_databases/1, create_db/2, delete_db/2, open_doc/3, open_doc/4, - get_db_info/2]). + get_db_info/2, db_path/2]). + +-include("../../couch/src/couch_db.hrl"). % db operations +-spec db_path(bstring(), bstring()) -> bstring(). +db_path(RawUri, Customer) -> + CustomerUri = generate_customer_path(RawUri, Customer), + {Path, _, _} = mochiweb_util:urlsplit_path(CustomerUri), + Path. + all_databases(Customer) -> fabric_db:all_databases(Customer). @@ -22,4 +30,23 @@ open_doc(Db, DocId, Options) -> fabric_doc:open_doc(Db, DocId, Options). open_doc(Db, DocId, Revs, Options) -> - fabric_open:open_doc(Db, DocId, Revs, Options). + fabric_doc:open_doc(Db, DocId, Revs, Options). + + + +%% +%% internal +%% +generate_customer_path("/", _Customer) -> + ""; +generate_customer_path("/favicon.ico", _Customer) -> + "favicon.ico"; +generate_customer_path([$/,$_|Rest], _Customer) -> + lists:flatten([$_|Rest]); +generate_customer_path([$/|RawPath], Customer) -> + case Customer of + "" -> + RawPath; + Else -> + lists:flatten([Else, "%2F", RawPath]) + end. diff --git a/src/fabric_api.erl b/src/fabric_api.erl deleted file mode 100644 index 53dc96e3..00000000 --- a/src/fabric_api.erl +++ /dev/null @@ -1,118 +0,0 @@ -%% This is a raw Erlang API for CouchDB in a Cloudant cluster -%% It makes use of clustering facilities - --module(fabric_api). --author('adam@cloudant.com'). --author('brad@cloudant.com'). - --include("../../couch/src/couch_db.hrl"). - --compile(export_all). - --type response() :: any(). - -%% dialyzer doesn't have recursive types, so this is necessarily wrong --type ejson_value() :: true | false | number() | bstring() | list(). --type ejson() :: {[{bstring(), ejson_value()}]}. - -%% Database - --spec db_path(bstring(), bstring()) -> bstring(). -db_path(RawUri, Customer) -> - showroom_db:db_path(RawUri, Customer). - --spec all_databases(string()) -> {ok, [bstring()]}. -all_databases(Customer) -> - fabric:all_databases(Customer). - --spec create_db(bstring(), [any()]) -> {ok, #db{}} | {error, any()}. -create_db(DbName, Options) -> - fabric:create_db(DbName, Options). - --spec delete_db(bstring(), [any()]) -> ok | not_found | {error, atom()}. -delete_db(DbName, Options) -> - fabric:delete_db(DbName, Options). - --spec open_db(bstring(), [any()]) -> {ok, #db{}} | {error, any()}. -open_db(DbName, Options) -> - fabric:open_db(DbName, Options). - --spec close_db(#db{}) -> ok. -close_db(Db) -> - showroom_db:close_db(Db). - --spec get_db_info(#db{}, bstring()) -> {ok, [{atom(), any()}]}. -get_db_info(Db, Customer) -> - fabric:get_db_info(Db, Customer). - --spec replicate_db(ejson(), #user_ctx{}) -> {ok, ejson()}. -replicate_db(PostBody, UserCtx) -> - showroom_rep:replicate(PostBody, UserCtx). - --spec ensure_full_commit(#db{}) -> {ok, InstanceStartTime::bstring()}. -ensure_full_commit(Db) -> - showroom_db:ensure_full_commit(Db), - {ok, <<"0">>}. - - -%% Document - -att_receiver(Req, Length) -> - showroom_att:receiver(Req, Length). - --spec get_missing_revs(#db{}, [{docid(), [revision()]}]) -> - {ok, [{docid(), [revision()]}]}. -get_missing_revs(Db, IdsRevs) -> - showroom_doc:get_missing_revs(Db, IdsRevs). - -open_doc(DbName, DocId) -> - open_doc(DbName, DocId, nil, []). - --spec open_doc(bstring(), docid(), [any()]) -> - {ok, #doc{}} | {not_found, deleted | missing}. -open_doc(DbName, DocId, Options) -> - open_doc(DbName, DocId, nil, Options). - -open_doc(DbName, DocId, Revs, Options) -> - fabric:open_doc(DbName, DocId, Revs, Options). - --spec open_doc_revs(bstring(), docid(), [revision()], [any()]) -> - {ok, [{ok, #doc{}} - | {{not_found, deleted | missing}, revision()}]}. -open_doc_revs(DbName, DocId, Revs, Options) -> - open_doc(DbName, DocId, Revs, Options). - -update_doc(Db, Doc) -> - update_doc(Db, Doc, []). - --spec update_doc(#db{}, #doc{}, [any()]) -> {ok, revision()}. -update_doc(Db, Doc, Options) -> - showroom_doc:update_doc(Db, Doc, Options). - -update_docs(Db, Docs, Options) -> - update_docs(Db, Docs, Options, interactive_edit). - --spec update_docs(#db{}, [#doc{}], [any()], interactive_edit | - replicated_changes) -> {ok, [{ok, revision()}]}. -update_docs(Db, Docs, Options, Type) -> - showroom_doc:update_docs(Db, Docs, Options, Type). - - -%% View - --spec all_docs_view(response(), #db{}, nil | list(), #view_query_args{}) -> - {ok, any()}. -all_docs_view(Resp, Db, Keys, QueryArgs) -> - showroom_view:all_docs(Resp, Db, Keys, QueryArgs). - --spec design_view(response(), #db{}, bstring(), bstring(), nil | list(), - #view_query_args{}) -> any(). -design_view(Resp, Db, Id, Name, Keys, QueryArgs) -> - showroom_view:design(Resp, Db, Id, Name, Keys, QueryArgs). - -list_view(Req, Db, DesignId, ViewName, Keys, QueryArgs, QueryServer) -> - showroom_view:list(Req, Db, DesignId, ViewName, Keys, QueryArgs, QueryServer). - --spec get_view_group_info(#db{}, bstring()) -> {ok, [{atom(), any()}]}. -get_view_group_info(Db, DesignId) -> - showroom_view:group_info(Db, DesignId). diff --git a/src/fabric_doc.erl b/src/fabric_doc.erl index 463a3a9b..407a9187 100644 --- a/src/fabric_doc.erl +++ b/src/fabric_doc.erl @@ -13,6 +13,8 @@ open_doc(DbName, DocId, Opts) -> case fabric_util:recv(Workers, #shard.ref, fun handle_open_doc/3, Acc0) of {ok, #doc{deleted=true}} when SuppressDeletedDoc -> {not_found, deleted}; + {ok, {not_found, missing}} -> + {not_found, missing}; Else -> Else end. diff --git a/src/fabric_util.erl b/src/fabric_util.erl index 347670a4..38f0b9f3 100644 --- a/src/fabric_util.erl +++ b/src/fabric_util.erl @@ -56,7 +56,7 @@ process_message(RefList, Keypos, Fun, Acc0, TimeoutRef, PerMsgTO) -> {ok, Acc0}; RefPart -> % call the Fun that understands the message - ?debugFmt("~nAcc0: ~p~n", [Acc0]), + %?debugFmt("~nAcc0: ~p~n", [Acc0]), Fun(RefPart, Msg, Acc0) end; {rexi_DOWN, _RexiMonPid, ServerPid, Reason} = Msg -> |