221V 1 year ago
parent
commit
85f889038f

+ 1 - 10
include/api.hrl

@@ -3,16 +3,7 @@
 
 -include("metainfo.hrl").
 
-% exports
-
--export([start/0,stop/0]).                                        % service
--export([destroy/0,join/0,join/1,init/2]).                        % schema change
--export([modules/0,containers/0,tables/0,table/1,version/0]).     % meta info
--export([create/1,add/1,link/1,unlink/1,remove/2]).               % chain ops
--export([put/1,delete/2,next_id/2]).                              % raw ops
--export([get/2,get/3,index/3]).                                   % read ops
--export([load_db/1,save_db/1]).                                   % import/export
-
+% exports - moved to kvs.erl
 
 % service
 

+ 92 - 5
src/kvs.erl

@@ -1,6 +1,94 @@
 -module(kvs).
--copyright('Synrc Research Center s.r.o.').
--compile([export_all, nowarn_export_all]).
+%%-copyright('Synrc Research Center s.r.o.').
+
+
+-export([start/0, stop/0]).                                        % service
+-export([destroy/0, join/0, join/1, init/2]).                      % schema change
+-export([modules/0, containers/0, tables/0, table/1, version/0]).  % meta info
+-export([create/1, add/1, link/1, unlink/1, remove/2]).            % chain ops
+-export([put/1, put/2, delete/2, next_id/2]).                      % raw ops
+-export([get/2, get/3, index/3]).                                  % read ops
+-export([load_db/1, save_db/1]).                                   % import/export
+
+-export([
+  change_storage/2,
+  entries/3,
+  count/1,
+  all/1,
+  fold/6,
+  info/1,
+  dir/0,
+  
+  generation/2,
+  norm/3,
+  limit/2,
+  forbid/1,
+
+  change_storage/1,  %% todo check what exports not needs
+  change_storage/3,
+  dir/1,
+  info/2,
+  ensure_link/2,
+  append/2,
+  reverse/1,
+  relink/3,
+  takeoff/3,
+  do_remove/2,
+  fold/7,
+  entries/4,
+  add_seq_ids/0,
+  count/2,
+  all/2,
+  save/2,
+  load/1,
+  notify/2,
+  config/1,
+  config/2,
+  config/3,
+  log_modules/0,
+  log/4,
+  info/3,
+  warning/3,
+  error/3,
+  dump/0,
+  dump/1,
+  dump_info/1,
+  dump_format/1,
+  range/2,
+  topleft/2,
+  last/2,
+  find/3,
+  lookup/2,
+  rotate_new/0,
+  rotate/1,
+  load_partitions/0,
+  rnorm/2,
+  rlist/1,
+  shd/1,
+  wait/0,
+  stl/1,
+  dat/1,
+  omitone/1,
+  limit/0,
+  load_config/0,
+  store/2,
+  rname/1,
+  nname/1,
+  fold/1,
+  top/1,
+  name/1,
+  id_seq/1,
+  last_disc/1,
+  last_table/1,
+  fold_tables/0,
+  range/3,
+  update_config/2,
+  update_list/3,
+  setkey/4,
+  test/0,
+  test/1
+]).
+
 
 %-include_lib("stdlib/include/qlc.hrl").
 
@@ -50,7 +138,7 @@ limit(_Table,_Key)     -> 25000.
 
 forbid(user)           -> 5;
 forbid(comment)        -> 5;
-forbid(____)           -> 5.
+forbid(_)              -> 5.
 
 % Implementation
 
@@ -93,7 +181,6 @@ create(ContainerName, Id, Driver) ->
     Id.
 
 ensure_link(Record, #kvs{mod=_Store}=Driver) ->
-
     Id    = element(2,Record),
     Type  = rname(element(1,Record)),
     CName = element(#iterator.container,Record),
@@ -244,7 +331,7 @@ fold(Fun,Acc,Table,Start,Count,Direction,Driver) ->
 entries({error,_},_,_,_)      -> [];
 entries({ok,T},N,C,Driver) ->
     lists:reverse(fold(fun(A,Acc) -> [A|Acc] end,[],N,element(#container.top,T),C,#iterator.prev,Driver)).
-    
+
 
 add_seq_ids() ->
     Init = fun(Key) ->

+ 10 - 3
src/kvs_acl.erl

@@ -1,7 +1,5 @@
 -module(kvs_acl).
--copyright('Synrc Research Center s.r.o.').
-
--compile([export_all, nowarn_export_all]).
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/kvs.hrl").
 -include_lib("kvs/include/metainfo.hrl").
@@ -9,6 +7,14 @@
 -include_lib("kvs/include/user.hrl").
 
 
+-export([
+  metainfo/0,
+  define_access/3,
+  check/1,
+  check_access/2
+]).
+
+
 metainfo() ->
     #schema{name=kvs,tables=[
         #table{name=acl,container=true,fields=record_info(fields,acl),keys=[id,accessor]},
@@ -36,3 +42,4 @@ check_access(Id, Feature) ->
     case kvs:get(user, Id) of
         {ok, User} -> check_access(User, Feature);
         E -> E end.
+

+ 9 - 2
src/kvs_feed.erl

@@ -1,7 +1,6 @@
 -module(kvs_feed).
--copyright('Synrc Research Center, s.r.o.').
+%%-copyright('Synrc Research Center, s.r.o.').
 
--compile([export_all, nowarn_export_all]).
 
 -include_lib("kvs/include/kvs.hrl").
 -include_lib("kvs/include/config.hrl").
@@ -11,6 +10,13 @@
 -include_lib("kvs/include/metainfo.hrl").
 
 
+-export([
+  metainfo/0,
+  core/0,
+  feeds/0
+]).
+
+
 metainfo() ->  #schema{name=kvs,tables= core() ++ feeds() }.
 
 core()     -> [ #table{name=config,fields=record_info(fields,config)},
@@ -21,3 +27,4 @@ core()     -> [ #table{name=config,fields=record_info(fields,config)},
 feeds()    -> [ #table{name=entry,container=true,fields=record_info(fields,entry)},
                 #table{name=comment,container=true,fields=record_info(fields,comment)},
                 #table{name=feed,container=true,fields=record_info(fields,feed)} ].
+

+ 11 - 2
src/kvs_subscription.erl

@@ -1,10 +1,18 @@
 -module(kvs_subscription).
--copyright('Synrc Research Center s.r.o.').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/subscription.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  metainfo/0,
+  subscribe/2,
+  unsubscribe/2,
+  subscriptions/1,
+  subscribed/1,
+  subscribed/2
+]).
 
 
 metainfo() ->
@@ -24,3 +32,4 @@ subscribed(Who, Whom) ->
     case kvs:get(subscription, {Who, Whom}) of
         {ok, _} -> true;
         _ -> false end.
+

+ 5 - 2
src/kvs_user.erl

@@ -1,11 +1,14 @@
 -module(kvs_user).
--copyright('Synrc Research Center s.r.o.').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/user.hrl").
 -include_lib("kvs/include/group.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  metainfo/0
+]).
 
 
 metainfo() ->

+ 24 - 2
src/store/store_fs.erl

@@ -1,11 +1,32 @@
 -module(store_fs).
--copyright('Synrc Research Center s.r.o.').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/config.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 -include_lib("stdlib/include/qlc.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  destroy/0,
+  version/0,
+  dir/0,
+  join/1,
+  change_storage/2,
+  initialize/0,
+  index/3,
+  get/2,
+  put/1,
+  delete/2,
+  count/1,
+  all/1,
+  next_id/2,
+  create_table/2,
+  add_table_index/2,
+  encode/1,
+  hex_octet/1
+]).
 
 
 start()    -> ok.
@@ -88,3 +109,4 @@ hex_octet(N) -> [N - 10 + $a].
 escape_byte(C) -> normalize(hex_octet(C)).
 normalize(H) when length(H) == 1 -> "%0" ++ H;
 normalize(H) -> "%" ++ H.
+

+ 22 - 3
src/store/store_kai.erl

@@ -1,12 +1,31 @@
 -module(store_kai).
--author('Maxim Sokhatsky').
--copyright('Synrc Research Center s.r.o.').
+%%-author('Maxim Sokhatsky').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/config.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 -include_lib("stdlib/include/qlc.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  version/0,
+  join/1,
+  initialize/0,
+  dir/0,
+  put/1,
+  kai_put/1,
+  update/2,
+  get/2,
+  kai_get/1,
+  delete/2,
+  kai_delete/1,
+  key_to_bin/1,
+  all/1,
+  all_by_index/3,
+  table_to_num/1
+]).
 
 
 -record(data, { key, bucket, last_modified, vector_clocks, checksum, flags, value }).

+ 30 - 2
src/store/store_mnesia.erl

@@ -1,12 +1,39 @@
 -module(store_mnesia).
--copyright('Synrc Research Center s.r.o.').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/config.hrl").
 -include_lib("kvs/include/kvs.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 -include_lib("stdlib/include/qlc.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  destroy/0,
+  version/0,
+  dir/0,
+  join/1,
+  change_storage/2,
+  initialize/0,
+  index/3,
+  get/2,
+  put/1,
+  delete/2,
+  count/1,
+  all/1,
+  next_id/2,
+  many/1,
+  void/1,
+  info/1,
+  create_table/2,
+  add_table_index/2,
+  exec/1,
+  just_one/1,
+  add/1,
+  remove/2,
+  context/0
+]).
 
 
 start()    -> mnesia:start().
@@ -69,3 +96,4 @@ just_one(Fun) ->
 add(Record) -> mnesia:activity(context(),fun() -> kvs:append(Record,#kvs{mod=?MODULE}) end).
 remove(Record,Id) -> mnesia:activity(context(),fun() -> kvs:takeoff(Record,Id,#kvs{mod=?MODULE}) end).
 context() -> kvs:config(kvs,mnesia_context,async_dirty).
+

+ 40 - 4
src/store/store_mongo.erl

@@ -1,11 +1,47 @@
 -module(store_mongo).
--author("Vitaly Shutko").
--author("Oleg Zinchenko").
--copyright('Synrc Research Center s.r.o.').
+%%-author("Vitaly Shutko").
+%%-author("Oleg Zinchenko").
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/metainfo.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  version/0,
+  join/1,
+  connect/0,
+  connect/1,
+  connect/2,
+  config/0,
+  transaction/1,
+  dir/0,
+  destroy/0,
+  next_id/2,
+  to_binary/1,
+  to_binary/2,
+  make_document/3,
+  list_to_doc/2,
+  make_id/1,
+  make_field/1,
+  make_record/2,
+  decode_value/1,
+  decode_id/1,
+  doc_to_proplist/1,
+  doc_to_proplist/2,
+  get/2,
+  put/1,
+  mongo_put/1,
+  delete/2,
+  mongo_find/2,
+  all/1,
+  index/3,
+  create_table/2,
+  add_table_index/2,
+  count/1
+]).
+
 
 -define(POOL_NAME,mongo_pool).
 

+ 32 - 3
src/store/store_redis.erl

@@ -1,12 +1,40 @@
 -module(store_redis).
--author('Andrey Martemyanov').
--copyright('Synrc Research Center s.r.o.').
+%%-author('Andrey Martemyanov').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/config.hrl").
 -include_lib("kvs/include/kvs.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  c/0,
+  destroy/0,
+  version/0,
+  dir/0,
+  join/1,
+  change_storage/2,
+  initialize/0,
+  b2i/1,
+  redis_table/1,
+  redis_key/2,
+  redis_keys/1,
+  redis_put/1,
+  redis_get/2,
+  redis_get/1,
+  redis_transaction/1,
+  index/3,
+  get/2,
+  put/1,
+  delete/2,
+  count/1,
+  all/1,
+  next_id/2,
+  create_table/2,
+  add_table_index/2
+]).
 
 
 start() -> erase(eredis_pid), {ok,C}=eredis:start_link(), erlang:put(eredis_pid,C), ok.
@@ -80,3 +108,4 @@ next_id(RecordName,Incr) ->
     b2i(Value).
 create_table(_Name,_Options) -> ok.
 add_table_index(_Record,_Field) -> not_implemented.
+

+ 29 - 3
src/store/store_riak.erl

@@ -1,6 +1,6 @@
 -module(store_riak).
--author('Maxim Sokhatsky <maxim@synrc.com>').
--copyright('Synrc Research Center s.r.o.').
+%%-author('Maxim Sokhatsky <maxim@synrc.com>').
+%%-copyright('Synrc Research Center s.r.o.').
 
 -include_lib("kvs/include/config.hrl").
 -include_lib("kvs/include/user.hrl").
@@ -11,7 +11,32 @@
 -include_lib("kvs/include/feed.hrl").
 -include_lib("kvs/include/acl.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  start/0,
+  stop/0,
+  version/0,
+  join/1,
+  initialize/0,
+  dir/0,
+  riak_clean/1,
+  make_object/1,
+  make_indices/1,
+  put/1,
+  riak_put/1,
+  get/2,
+  riak_get/2,
+  delete/2,
+  delete_by_index/3,
+  key_to_bin/1,
+  all/1,
+  all_by_index/3,
+  riak_get_raw/1,
+  next_id/1,
+  subscriptions/1,
+  subscribed/1,
+  author_comments/1
+]).
 
 
 start() -> ok.
@@ -168,3 +193,4 @@ subscribed(Who) -> all_by_index(subscription, <<"subs_whom_bin">>, list_to_binar
 author_comments(Who) ->
     EIDs = [E || #comment{entry_id=E} <- all_by_index(comment,<<"author_bin">>, Who) ],
     lists:flatten([ all_by_index(entry,<<"entry_bin">>,EID) || EID <- EIDs]).
+

+ 51 - 3
src/store/store_sql.erl

@@ -1,13 +1,60 @@
 -module(store_sql).
--author('Daniil Churikov').
--author('Max Davidenko').
+%%-author('Daniil Churikov').
+%%-author('Max Davidenko').
 
--compile([export_all, nowarn_export_all]).
 
 -include_lib("kvs/include/sql.hrl").
 -include_lib("kvs/include/metainfo.hrl").
 
 
+-export([
+  start/0,
+  stop/0,
+  version/0,
+  join/0,
+  join/1,
+  initialize/0,
+  insert/3,
+  select_pk/3,
+  select/3,
+  update_pk/3,
+  update_pk_diff/4,
+  update/4,
+  delete_pk/3,
+  delete/3,
+  prepare_insert/3,
+  prepare_select/3,
+  prepare_update/4,
+  prepare_delete/3,
+  build/1,
+  e2l/1,
+  skip/3,
+  qdata/4,
+  returning/3,
+  where/2,
+  predicate/2,
+  op_to_bin/1,
+  order_by/1,
+  build_return/1,
+  build_where/1,
+  build_order_by/1,
+  predicate_val/1,
+  set_predicate_val/2,
+  map2/3,
+  intersperse/2,
+  intersperse2/4,
+  put/1,
+  sql_put/1,
+  get/2,
+  sql_get/2,
+  proplistToRecord/2,
+  convertBindingVal/1,
+  mapResult/2,
+  extendedQuery/2,
+  connection/0
+]).
+
+
 -define(SETTINGS, #sql_settings{placeholder = fun (_, Pos, _) -> PosBin = integer_to_binary(Pos), <<"$", PosBin/binary>> end}).
 
 
@@ -340,3 +387,4 @@ connection() ->
                     wf:cache(pgsql_conn,Conn),
                     Conn;
       Connection -> Connection end.
+

+ 15 - 1
test/kvs_SUITE.erl

@@ -3,7 +3,20 @@
 -include_lib("common_test/include/ct.hrl").
 -include_lib("kvs/include/entry.hrl").
 
--compile([export_all, nowarn_export_all]).
+
+-export([
+  suite/0,
+  all/0,
+  groups/0,
+  init_per_suite/1,
+  end_per_suite/1,
+  init_per_group/2,
+  end_per_group/2,
+  access/1,
+  comment/1,
+  user/1,
+  entry/1
+]).
 
 
 suite() -> [{timetrap,{seconds,30}}].
@@ -45,3 +58,4 @@ entry(Config) ->
     List == [{1,1},{2,1}],
     ct:log("-> List ~p~n", [List]),
     ok.
+