Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Split create_token into find/create.
Browse files Browse the repository at this point in the history
  • Loading branch information
archaelus committed May 20, 2013
1 parent 15bb70f commit 70c89f9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/nsync_callback.erl
Expand Up @@ -157,15 +157,25 @@ create_channel(ChannelId, Dict) ->
end.

create_token(Id, Dict) ->
case dict_find(<<"ch">>, Dict) of
undefined ->
case find_token(Id, Dict) of
{error, missing_channel} ->
?ERR("~p ~p ~p ~p",
[create_token, missing_ch, Id, dict:to_list(Dict)]);
{ok, Token} ->
logplex_token:cache(Token),
Token
end.

find_token(Id, Dict) ->
case dict_find(<<"ch">>, Dict) of
undefined ->
{error, missing_channel};
Val1 ->
Ch = convert_to_integer(Val1),
Name = dict_find(<<"name">>, Dict),
Token = logplex_token:new(Id, Ch, Name),
logplex_token:cache(Token),
{ok, Token}
end.
Token
end.

Expand Down

0 comments on commit 70c89f9

Please sign in to comment.