Skip to content

Commit

Permalink
Merge branch 'release/1.1.13'
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Oct 8, 2015
2 parents a063080 + 30fef62 commit f682562
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/leo_backend_db.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{application, leo_backend_db,
[
{description, "Leo Backend db"},
{vsn, "1.1.12"},
{vsn, "1.1.13"},
{id, "leo_backend_db"},
{registered, []},
{applications, [kernel, stdlib]},
Expand Down
31 changes: 22 additions & 9 deletions src/leo_backend_db_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,29 @@ fetch(InstanceName, KeyBin, Fun, MaxKeys) ->
[] ->
not_found;
[{InstanceName, List}] ->
Res = lists:foldl(fun(Id, Acc) ->
case ?SERVER_MODULE:fetch(Id, KeyBin, Fun, MaxKeys) of
{ok, Ret} -> [Acc|Ret];
_Other -> Acc
end
end, [], List),
fetch(lists:sublist(lists:reverse(lists:flatten(Res)), MaxKeys))
case catch lists:foldl(
fun(Id, Acc) ->
case ?SERVER_MODULE:fetch(Id, KeyBin, Fun, MaxKeys) of
{ok, Ret} ->
[Acc|Ret];
not_found ->
Acc;
{error, Cause} ->
erlang:error(Cause)
end
end, [], List) of
{'EXIT', Cause} ->
{error, Cause};
RetL ->
fetch(lists:sublist(
lists:reverse(
lists:flatten(RetL)), MaxKeys))
end
end.
fetch([]) -> not_found;
fetch(Res) -> {ok, Res}.
fetch([]) ->
not_found;
fetch(Res) ->
{ok, Res}.


%% @doc Retrieve a first record from backend-db.
Expand Down
8 changes: 7 additions & 1 deletion src/leo_backend_db_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ handle_call({delete, KeyBin}, _From, #state{db = DBModule,

handle_call({fetch, KeyBin, Fun, MaxKeys}, _From, #state{db = DBModule,
handler = Handler} = State) ->
Reply = erlang:apply(DBModule, prefix_search, [Handler, KeyBin, Fun, MaxKeys]),
Reply = case catch erlang:apply(DBModule, prefix_search,
[Handler, KeyBin, Fun, MaxKeys]) of
{'EXIT', Cause} ->
{error, Cause};
Ret ->
Ret
end,
{reply, Reply, State};

handle_call(first, _From, #state{db = DBModule,
Expand Down

0 comments on commit f682562

Please sign in to comment.