api.hrl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -ifndef(API_HRL).
  2. -define(API_HRL, true).
  3. -include("metainfo.hrl").
  4. % exports - moved to kvs.erl
  5. % service
  6. -spec start() -> ok | {error,any()}.
  7. -spec stop() -> stopped.
  8. % schema change
  9. -spec destroy() -> ok.
  10. -spec join() -> ok | {error,any()}.
  11. -spec join(Node :: string()) -> [{atom(),any()}].
  12. -spec init(Backend :: atom(), Module :: atom()) -> list(#table{}).
  13. % meta info
  14. -spec modules() -> list(atom()).
  15. -spec containers() -> list({atom(),list(atom())}).
  16. -spec tables() -> list(#table{}).
  17. -spec table(Tab :: atom()) -> #table{}.
  18. -spec version() -> {version,string()}.
  19. % chain ops
  20. -spec create(Container :: atom()) -> integer().
  21. -spec add(Record :: tuple()) -> {ok,tuple()} | {error,exist} | {error,no_container} | {error,just_added} | {aborted,any()}.
  22. -spec link(Record :: tuple()) -> {ok,tuple()} | {error, not_found} | {error,no_container} | {error,just_added}.
  23. -spec unlink(Record :: tuple()) -> {ok,tuple()} | {error,no_container}.
  24. -spec remove(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  25. % raw ops
  26. -spec put(Record :: tuple()) -> ok | {error,any()}.
  27. -spec delete(Tab :: atom(), Key :: any()) -> ok | {error,any()}.
  28. % read ops
  29. -spec get(Tab :: atom(), Key :: any()) -> {ok,any()} | {error,duplicated} | {error,not_found}.
  30. -spec get(Tab :: atom(), Key :: any(), Value :: any()) -> {ok,any()}.
  31. -spec index(Tab :: atom(), Key :: any(), Value :: any()) -> list(tuple()).
  32. % import/export
  33. -spec load_db(Path :: string()) -> list(ok | {error,any()}).
  34. -spec save_db(Path :: string()) -> ok | {error,any()}.
  35. -endif.