Skip to content

Commit

Permalink
[#62] Renamed all sumo_repo* modules to sumo_store*.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfacorro committed Nov 17, 2014
1 parent 3c11470 commit c6b1279
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 72 deletions.
105 changes: 105 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Changelog

## `master`

### Added

- [#21] asc/desc option for ordering.
- `CONTRIBUTORS.md`.
- [#3] Full conditional logic for MySQL and MongoDB.
- [#61] Add `erlang.mk`.
- [#67] GitHub page http://inaka.github.io/sumo_db/.
- [#74] ElasticSearch backend and repo.
- [#77] Defaults for worker pool's overrun configuration values.
- [#51] Use a proper overrun warning for wpool.

### Deprecated

- [#62] Renamed all `sumo_repo*` modules to `sumo_store*`. Existing repo modules in your application should be updated with the new names.

### Removed

- [#87] Removed SQLite repo and dependency.

### Fixed

- [#70] Log execution time in miliseconds.
- [#72] Provide version for dependencies.
- [#79] Remove git account for dependencies.
- [#81] Blog example doesn't build cleanly.
- [#80] Fixed the run escript to not throw errors for make blog.

## 0.1.3 - 2014-09-23

### Added

- [#68] Accept `wpool_opts` entry in configuration file.

### Deprecated

- None.

### Removed

- None.

### Fixed

- None.

## 0.1.2 - 2014-07-11

### Added

- [#58] Upgraded rebar to 2.5.0 so that it plays nicely with erlang.mk.

### Deprecated

- None.

### Removed

- None.

### Fixed

- None.

## 0.1.1 - 2014-07-02

### Added

- [#56] Ready for R17. Fixed all compilation warnings.

### Deprecated

- None.

### Removed

- None.

### Fixed

- None.

## 0.1.0 - 2014-06-04

### Added

- All basic sumo_db features:
- Backends
- Repos
- Events

### Deprecated

- None.

### Removed

- None.

### Fixed

- None.
16 changes: 10 additions & 6 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
## Contributors
Besides all the devs at [@inaka](https://github.com/inaka), we want to specially thank these rockstars:
Besides all the devs at [@inaka](https://github.com/inaka), we want to specially
thank these rockstars:

* [@marcelog](https://github.com/marcelog), who created the project and guided us all in the path of the repository
* [@AxisOfEval](https://github.com/AxisOfEval), who has jumped right in and started sharing his knowledge (and code) with us out of the blue
* [@marcelog](https://github.com/marcelog), who created the project and guided
us all in the path of the repository
* [@AxisOfEval](https://github.com/AxisOfEval), who has jumped right in and
started sharing his knowledge (and code) with us out of the blue.

*NOTE:* We (i.e. [@inaka](https://github.com/inaka)) will keep adding people to this list as soon as they make
valuable contributions to the project, but if you feel someone (even you) is missing feel free to send us a PR
to correct that mistake right away :)
*NOTE:* We (i.e. [@inaka](https://github.com/inaka)) will keep adding people to
this list as soon as they make valuable contributions to the project, but if you
feel someone (even you) is missing feel free to send us a PR to correct that
mistake right away :)
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ And you can check all of our open-source projects at [inaka.github.io](http://in
For example this `[{age, desc}, {name, asc}]]` will sort descendently by `age` and ascendently by `name`.

## Example

See: [**examples/blog**](https://github.com/inaka/sumo_db/tree/master/examples/blog)
for a full example. To run it, while being in the top level directory:

make all blog

## Contributors
We want to thank all of [our contributors](CONTRIBUTORS.md) for their hard work :muscle:
We want to thank all of [our contributors](CONTRIBUTORS.md) for their hard work :muscle:.
5 changes: 2 additions & 3 deletions examples/blog/blog.config
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
]}
]},
{repositories, [
{mysql, sumo_repo_mysql, [
{mysql, sumo_store_mysql, [
{storage_backend, mysql_backend},
{workers, 5}
]},
{mongo, sumo_repo_mongo, [
{mongo, sumo_store_mongo, [
{storage_backend, mongo_backend},
{workers, 5}
]}
Expand All @@ -55,4 +55,3 @@
]}
]}
].

2 changes: 1 addition & 1 deletion examples/blog/src/blog_post.erl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ sumo_schema() ->
% -spec total_posts(sumo:schema_name(), State ) -> {ok, {raw, non_neg_integer()}, State} | {ok, error, State}.
% count(DocName, State) ->
% Sql = "SELECT COUNT(1) FROM `" ++ atom_to_list(DocName) ++ "`",
% Result = sumo_repo_mysql:execute(Sql, State),
% Result = sumo_store_mysql:execute(Sql, State),
% case Result of
% #result_packet{rows=[[N]]} -> {ok, {raw, N}, State};
% _ -> {ok, error, State}
Expand Down
2 changes: 1 addition & 1 deletion examples/elastic-blog/config/blog.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]},
{repositories,
[
{elasticsearch_repo, sumo_repo_elasticsearch,
{elasticsearch_repo, sumo_store_elasticsearch,
[
{storage_backend, elasticsearch_backend},
{workers, 10}
Expand Down
13 changes: 0 additions & 13 deletions examples/elastic-blog/src/blog_post.erl
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,3 @@ sumo_schema() ->
sumo:new_field(content, string),
sumo:new_field(author_id, string)
]).

%% We don't have the extends module attribute in R16, so this was moved out from
%% the old blog_post_repo in the example, we should allocate some time to create
%% a proper parse transform for this.
% -spec total_posts(sumo:schema_name(), State ) ->
% {ok, {raw, non_neg_integer()}, State} | {ok, error, State}.
% count(DocName, State) ->
% Sql = "SELECT COUNT(1) FROM `" ++ atom_to_list(DocName) ++ "`",
% Result = sumo_repo_mysql:execute(Sql, State),
% case Result of
% #result_packet{rows=[[N]]} -> {ok, {raw, N}, State};
% _ -> {ok, error, State}
% end.
20 changes: 10 additions & 10 deletions src/sumo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ find(DocName, Id) ->
%% @doc Returns all docs from the given repo.
-spec find_all(schema_name()) -> [user_doc()].
find_all(DocName) ->
case sumo_repo:find_all(sumo_internal:get_repo(DocName), DocName) of
case sumo_store:find_all(sumo_internal:get_repo(DocName), DocName) of
{ok, Docs} -> docs_wakeup(DocName, Docs);
Error -> throw(Error)
end.
Expand All @@ -113,7 +113,7 @@ find_all(DocName) ->
find_all(DocName, SortFields0, Limit, Offset) ->
SortFields = normalize_sort_fields(SortFields0),
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:find_all(Repo, DocName, SortFields, Limit, Offset) of
case sumo_store:find_all(Repo, DocName, SortFields, Limit, Offset) of
{ok, Docs} -> docs_wakeup(DocName, Docs);
Error -> throw(Error)
end.
Expand All @@ -122,7 +122,7 @@ find_all(DocName, SortFields0, Limit, Offset) ->
-spec find_by(schema_name(), conditions()) -> [user_doc()].
find_by(DocName, Conditions) ->
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:find_by(Repo, DocName, Conditions) of
case sumo_store:find_by(Repo, DocName, Conditions) of
{ok, Docs} -> docs_wakeup(DocName, Docs);
Error -> throw(Error)
end.
Expand All @@ -134,7 +134,7 @@ find_by(DocName, Conditions) ->
) -> [user_doc()].
find_by(DocName, Conditions, Limit, Offset) ->
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:find_by(Repo, DocName, Conditions, Limit, Offset) of
case sumo_store:find_by(Repo, DocName, Conditions, Limit, Offset) of
{ok, Docs} -> docs_wakeup(DocName, Docs);
Error -> throw(Error)
end.
Expand All @@ -147,7 +147,7 @@ find_by(DocName, Conditions, Limit, Offset) ->
find_by(DocName, Conditions, SortFields0, Limit, Offset) ->
SortFields = normalize_sort_fields(SortFields0),
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:find_by(
case sumo_store:find_by(
Repo, DocName, Conditions, SortFields, Limit, Offset
) of
{ok, Docs} -> docs_wakeup(DocName, Docs);
Expand All @@ -164,7 +164,7 @@ persist(DocName, State) ->
_ -> updated
end,
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:persist(Repo, sumo_internal:new_doc(DocName, PropList)) of
case sumo_store:persist(Repo, sumo_internal:new_doc(DocName, PropList)) of
{ok, NewDoc} ->
Ret = sumo_internal:wakeup(DocName, NewDoc),
sumo_event:dispatch(DocName, EventName, [Ret]),
Expand All @@ -176,7 +176,7 @@ persist(DocName, State) ->
-spec delete_all(schema_name()) -> non_neg_integer().
delete_all(DocName) ->
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:delete_all(Repo, DocName) of
case sumo_store:delete_all(Repo, DocName) of
{ok, NumRows} ->
case NumRows > 0 of
true -> sumo_event:dispatch(DocName, deleted_all);
Expand All @@ -199,7 +199,7 @@ delete(DocName, Id) ->
-spec delete_by(schema_name(), conditions()) -> non_neg_integer().
delete_by(DocName, Conditions) ->
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:delete_by(Repo, DocName, Conditions) of
case sumo_store:delete_by(Repo, DocName, Conditions) of
{ok, 0} ->
0;
{ok, NumRows} ->
Expand All @@ -218,7 +218,7 @@ create_schema(DocName) ->
%% repository.
-spec create_schema(schema_name(), atom()) -> ok.
create_schema(DocName, Repo) ->
case sumo_repo:create_schema(Repo, sumo_internal:get_schema(DocName)) of
case sumo_store:create_schema(Repo, sumo_internal:get_schema(DocName)) of
ok ->
sumo_event:dispatch(DocName, schema_created),
ok;
Expand All @@ -234,7 +234,7 @@ call(DocName, Function) ->
-spec call(schema_name(), atom(), [term()]) -> term().
call(DocName, Function, Args) ->
Repo = sumo_internal:get_repo(DocName),
case sumo_repo:call(Repo, DocName, Function, Args) of
case sumo_store:call(Repo, DocName, Function, Args) of
{ok, {docs, Docs}} -> docs_wakeup(DocName, Docs);
{ok, {raw, Value}} -> Value
end.
Expand Down
2 changes: 1 addition & 1 deletion src/sumo_repo.erl → src/sumo_store.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
%%% @end
%%% @copyright Inaka <[email protected]>
%%%
-module(sumo_repo).
-module(sumo_store).
-author("Marcelo Gornstein <[email protected]>").
-github("https://github.com/inaka").
-license("Apache License 2.0").
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
%%% @end
%%% @copyright Inaka <[email protected]>
%%%
-module(sumo_repo_elasticsearch).
-module(sumo_store_elasticsearch).
-author("Juan Facorro <[email protected]>").
-license("Apache License 2.0").

-behavior(sumo_repo).
-behavior(sumo_store).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exports.
Expand Down
4 changes: 2 additions & 2 deletions src/sumo_repo_mongo.erl → src/sumo_store_mongo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
%%% @end
%%% @copyright Inaka <[email protected]>
%%%
-module(sumo_repo_mongo).
-module(sumo_store_mongo).
-author("Marcelo Gornstein <[email protected]>").
-github("https://github.com/inaka").
-license("Apache License 2.0").

-behavior(sumo_repo).
-behavior(sumo_store).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exports.
Expand Down
4 changes: 2 additions & 2 deletions src/sumo_repo_mysql.erl → src/sumo_store_mysql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
%%% @end
%%% @copyright Inaka <[email protected]>
%%%
-module(sumo_repo_mysql).
-module(sumo_store_mysql).
-author("Marcelo Gornstein <[email protected]>").
-github("https://github.com/inaka").
-license("Apache License 2.0").

-include_lib("emysql/include/emysql.hrl").

-behavior(sumo_repo).
-behavior(sumo_store).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Exports.
Expand Down
4 changes: 2 additions & 2 deletions src/sumo_repo_sup.erl → src/sumo_store_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
%%% @end
%%% @copyright Inaka <[email protected]>
%%%
-module(sumo_repo_sup).
-module(sumo_store_sup).
-author("Marcelo Gornstein <[email protected]>").
-github("https://github.com/inaka").
-license("Apache License 2.0").

-define(CLD(Name, Module, Options),
{ Name
, {sumo_repo, start_link, [Name, Module, Options]}
, {sumo_store, start_link, [Name, Module, Options]}
, permanent
, 5000
, worker
Expand Down
2 changes: 1 addition & 1 deletion src/sumo_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ init([]) ->
{ok, {
{one_for_one, 5, 10},
[ ?SUP(sumo_backend_sup)
, ?SUP(sumo_repo_sup)
, ?SUP(sumo_store_sup)
]
}}.
Loading

0 comments on commit c6b1279

Please sign in to comment.