Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialyzer errors #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/canister.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

-record(canister_times, {
id,
last_access=os:timestamp() :: erlang:timestamp(),
last_update=os:timestamp() :: erlang:timestamp(),
last_access=os:timestamp() :: undefined | erlang:timestamp(),
last_update=os:timestamp() :: undefined | erlang:timestamp(),
deleted=undefined :: undefined | erlang:timestamp()
}).
10 changes: 6 additions & 4 deletions src/canister.erl
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ touch_local(ID) ->
touch_local(ID, Time) ->
update_access_time(ID, Time).

queue_delete(ID, Time) ->
canister_sync:send_delete(ID, Time).
queue_delete(ID, _Time) ->
canister_sync:send_delete(ID).

record_status(ID) ->
case deleted_time(ID) of
Expand Down Expand Up @@ -330,7 +330,9 @@ clear_untouched_sessions() ->
SessionsToSync = lists:filtermap(fun(Sess) ->
case clear_untouched_session(Sess) of
ok -> false;
{resync, _Node} -> {true, Sess#canister_times.id}
{resync, _Node} ->
{ID, _LastAccess} = Sess,
{true, ID}
end
end, Sessions),
lists:foreach(fun(ID) ->
Expand Down Expand Up @@ -372,7 +374,7 @@ latest_cluster_time(Type, ID, LastAccess) ->
case compare_latest_node_time(Nodes, Type, ID, LastAccess) of
ok ->
ok;
{Node, NewLastAccess} ->
{ok, Node, NewLastAccess} ->
{ok, NewLastAccess, Node}
end
end.
Expand Down
8 changes: 2 additions & 6 deletions src/canister_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ summarize() ->
Msgs = [format_config(Field) || Field <- Fields],
Nodes = default_cluster(),
ClusterMsg = format_cluster(Nodes),
Msg = [
"Nitrogen Canister Session Manager Configuration:\n",
ClusterMsg,
Msgs
],
io:format(Msg).
MsgHeader = "Nitrogen Canister Session Manager Configuration:\n~s~s",
io:format(MsgHeader, [ClusterMsg, Msgs]).

format_cluster([]) ->
"*** Canister: No auto-connected cluster nodes (default_cluster) configured. You'll have to manually connect nodes (net_kernel:connect_node(Node))\n";
Expand Down
9 changes: 7 additions & 2 deletions src/canister_sync.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
send_update/2,
send_update/3,
send_clear/2,
send_delete/1,
send_touch/2,
get_nodes/0,
get_node_to_resync/0
Expand Down Expand Up @@ -52,6 +53,9 @@ send_clear(ID, Time) ->
send_touch(ID, Time) ->
gen_server:cast(?SERVER, {cast, {touch, ID, Time}}).

send_delete(ID) ->
gen_server:cast(?SERVER, {cast, {delete, ID}}).

init([]) ->
ok = init_ets(),
auto_connect_nodes(),
Expand Down Expand Up @@ -176,6 +180,9 @@ handle_remote({touch, ID, Time}) ->
ok;
handle_remote({clear, ID, Time}) ->
canister:clear(ID, Time),
ok;
handle_remote({delete, ID}) ->
canister:delete(ID),
ok.

assemble_and_requeue(Nodes) ->
Expand All @@ -199,8 +206,6 @@ assemble_and_requeue(Nodes) ->
get_node_to_resync() ->
get_node_to_resync([node() | get_nodes()]).

get_node_to_resync([]) ->
undefined;
get_node_to_resync(Nodes) ->
case which_nodes_are_resyncing(Nodes) of
[] -> hd(Nodes);
Expand Down