Skip to content

Commit

Permalink
[#74] ElasticSearch blog example.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfacorro committed Oct 15, 2014
1 parent 8f11010 commit 5bd11c6
Show file tree
Hide file tree
Showing 14 changed files with 1,648 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ examples/blog/log
*.o
*.beam
*.plt
.rebar
.rebar
log*/
erl_crash.dump
6 changes: 6 additions & 0 deletions examples/elastic-blog/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PROJECT = blog

include erlang.mk

SHELL_PATH = -pa ebin -pa deps/*/ebin ../../ebin ../../deps/*/ebin
SHELL_OPTS = -s sync -s blog -s lager -config config/blog.config
19 changes: 19 additions & 0 deletions examples/elastic-blog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# About
This is an escript that uses sumo_db (and the code in ./src) to implement a blog.

It uses different repositories (mysql, mongo) just as an example and
to make a point about how easy it is to switch or mix different databases.

# Tour
* Start by taking a rough look at **./run**, and then **src/blog.erl**.
* Note how:
* The business logic is handled directly in the "entities" modules
(blog\_post, blog\_author, etc).
* The **blog** module is the main entry point to the CRUD routines.
* Along the code, you only interact very briefly (and simply) with the
**sumo** module.
* The impedance between db and entity representations is greatly
diminished by a clear abstraction level.

# How to run
./run
54 changes: 54 additions & 0 deletions examples/elastic-blog/config/blog.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{sasl, [
{sasl_error_logger, {file, "log/sasl-error.log"}},
{errlog_type, error},
{error_logger_mf_dir, "log/sasl"}, % Log directory
{error_logger_mf_maxbytes, 10485760}, % 10 MB max file size
{error_logger_mf_maxfiles, 5} % 5 files max
]},
{sumo_db,
[
{storage_backends,
[
{elasticsearch_backend, sumo_backend_elasticsearch,
[
{host, "127.0.0.1"},
{port, 9200},
{index, "blog"},
{poolsize, 10}
]}
]},
{repositories,
[
{elasticsearch_repo, sumo_repo_elasticsearch,
[
{storage_backend, elasticsearch_backend},
{workers, 10}
]}
]},
{docs,
[
{blog_post, elasticsearch_repo},
{blog_author, elasticsearch_repo},
{blog_reader, elasticsearch_repo},
{blog_vote, elasticsearch_repo}
]},
{events, []}
]},
{lager,
[
{colored, true},
{async_threshold, 200},
{async_threshold_window, 5},
{error_logger_hwm, 500},
{handlers,
[
{lager_console_backend, debug},
{lager_file_backend,
[
{"log/lager_error.log", debug, 10485760, "$D0", 5},
{"log/lager_console.log", debug, 10485760, "$D0", 5}
]}
]}
]}
].
Loading

0 comments on commit 5bd11c6

Please sign in to comment.