Make the repo a gen_server

This helps us make sure we only have one thread accessing a particular
repo at a time and hopefully help us be more in line with usual erlang
practices.
This commit is contained in:
Carlos Martín Nieto
2013-04-06 18:34:02 +02:00
parent 58aff1e129
commit 4f507b8146
2 changed files with 131 additions and 37 deletions

View File

@@ -8,15 +8,15 @@
-export([lookup/2, id/1]).
-spec lookup(repo(), oid() | iolist()) -> object().
lookup(#repo{handle=RepoHandle}, #oid{oid=Oid}) ->
case geef:object_lookup(RepoHandle, Oid) of
-spec lookup(pid(), oid() | iolist()) -> object().
lookup(Repo, #oid{oid=Oid}) ->
case geef_repo:lookup_object(Repo, Oid) of
{ok, Type, Handle} ->
{ok, #object{type=Type, handle=Handle}};
Other ->
Other
end;
lookup(Repo = #repo{}, Id) ->
lookup(Repo, Id) ->
lookup(Repo, geef_oid:parse(Id)).
id(#object{handle=Handle}) ->