anchor.diff:  -behaviour(gen_server).
   
   %% API
  --export([start_link/1, stop/0]).
  +-export([start_link/1, stop/0,
  +         request_lease/3, end_lease/2]).
   
   %% gen_server callbacks
   -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
  
positive.code:                                ,{attributes, record_info(fields, lease)}]),
      ok = mnesia:wait_for_tables([lease], 10000),
      lager:info("Lease table initialized"),
      {ok, [MaxLeaseTime]}.
  
  %%--------------------------------------------------------------------
  %% @private
  
negative.code: start_link(Args) ->
      gen_server:start_link({local, ?SERVER}, ?MODULE, Args, []).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Stops the server (only useful without a supervision tree)
  %%
  %% @spec stop() -> ok
  %% @end
  %%--------------------------------------------------------------------
  stop() ->
      gen_server:cast(?MODULE, stop).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Requests a new lease
  %%
  %% @spec request_lease(User, Repo, Path)) -> {ok, LeaseId}
  %%                                         | {busy, TimeRemaining}
  %% @end
  %%--------------------------------------------------------------------
  -spec request_lease(binary(), binary(), binary()) -> {ok, binary()}
                                                     | {busy, integer()}.
  request_lease(User, Repo, Path) when is_binary(User),
                                       is_binary(Repo),
                                       is_binary(Path) ->
      gen_server:call(?MODULE, {lease_req, new_lease, {User, Repo, Path}}).
  
  %%--------------------------------------------------------------------
  %% @doc
  %% Gives up an existing lease
  %%
  %% @spec end_lease(Path, Repo) -> ok | {error, lease_not_found}
  %% @end
  %%--------------------------------------------------------------------
  end_lease(Repo, Path) when is_binary(Repo), is_binary(Path) ->
      gen_server:call(?MODULE, {lease_req, end_lease, {Repo, Path}}).
  
  %%%===================================================================
  %%% gen_server callbacks
  