Skip to content

Commit

Permalink
Rename cache to history
Browse files Browse the repository at this point in the history
  • Loading branch information
joergen7 committed May 4, 2018
1 parent 57b7fbd commit a2fc2fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/cre.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ start( _Type, _Args ) ->
cowboy_router:compile(
[{'_', [
{"/[status.json]", cre_status_handler, []},
{"/cache.json", cre_cache_handler, []}
{"/history.json", cre_history_handler, []}
]}] ),

{ok, _} = cowboy:start_clear( status_listener,
Expand Down
4 changes: 2 additions & 2 deletions src/cre_cache_handler.erl → src/cre_history_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
%%
%% @end
%% -------------------------------------------------------------------
-module( cre_cache_handler ).
-module( cre_history_handler ).
-behavior( cowboy_handler ).

%%====================================================================
Expand All @@ -38,7 +38,7 @@

init( Req0, State ) ->

CacheMap = cre_master:get_cache( cre_master ),
CacheMap = cre_master:get_history( cre_master ),
Doc = jsone:encode( CacheMap ),

Reply =
Expand Down
18 changes: 9 additions & 9 deletions src/cre_master.erl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

%% API functions
-export( [start_link/0, start_link/1, add_worker/2, worker_result/4,
cre_request/4, stop/1, get_status/1, get_cache/1] ).
cre_request/4, stop/1, get_status/1, get_history/1] ).

%% gen_server callback functions
-export( [code_change/3, handle_call/3, handle_cast/2, handle_info/2, init/1,
Expand Down Expand Up @@ -142,12 +142,12 @@ get_status( CreName ) ->
Info.


-spec get_cache( CreName :: _ ) ->
#{ cache => [#{ app => _, delta => _ }] }.
-spec get_history( CreName :: _ ) ->
#{ history => [#{ app => _, delta => _ }] }.

get_cache( CreName ) ->
{ok, CacheMap} = gen_server:call( CreName, get_cache ),
CacheMap.
get_history( CreName ) ->
{ok, HistoryMap} = gen_server:call( CreName, get_history ),
HistoryMap.


%%====================================================================
Expand Down Expand Up @@ -439,11 +439,11 @@ handle_call( get_status, _From, CreState ) ->



handle_call( get_cache, _From, CreState ) ->
handle_call( get_history, _From, CreState ) ->

#cre_state{ cache = Cache } = CreState,
CacheMap = #{ cache => [#{ app => A, delta => R } || {A, R} <- maps:to_list( Cache )] },
{reply, {ok, CacheMap}, CreState};
HistoryMap = #{ history => [#{ app => A, delta => R } || {A, R} <- maps:to_list( Cache )] },
{reply, {ok, HistoryMap}, CreState};

handle_call( _Request, _From, CreState ) ->
{reply, {error, bad_msg}, CreState}.
Expand Down

0 comments on commit a2fc2fb

Please sign in to comment.