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

Commit

Permalink
Adds logplex_token:delete_by_id for nsync.
Browse files Browse the repository at this point in the history
  • Loading branch information
archaelus committed May 6, 2013
1 parent f27604d commit 868b8aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/logplex_token.erl
Expand Up @@ -32,6 +32,7 @@
,name/1
,cache/1
,delete/1
,delete_by_id/1
,delete_by_channel/1
,new/3
,new/2
Expand Down Expand Up @@ -140,6 +141,14 @@ delete(Token = #token{id = Id}) ->
ets:delete(?TOKEN_TAB, Id),
ets:delete_object(?CHAN_TOKEN_TAB, index_rec(Token)).

delete_by_id(Id) ->
case lookup(Id) of
Token = #token{} ->
delete(Token);
_ ->
ok
end.

delete_by_channel(ChannelId) when is_integer(ChannelId) ->
[ ets:delete(?TOKEN_TAB, Id)
|| #token_idx{id = Id} <- lookup_ids_by_channel(ChannelId) ],
Expand Down
2 changes: 1 addition & 1 deletion src/nsync_callback.erl
Expand Up @@ -92,7 +92,7 @@ handle({cmd, "del", [<<"ch:", Rest/binary>> | _Args]}) ->
handle({cmd, "del", [<<"tok:", Rest/binary>> | _Args]}) ->
Id = parse_id(Rest),
?INFO("at=delete type=token id=~p", [Id]),
logplex_token:delete(Id);
logplex_token:delete_by_id(Id);

handle({cmd, "del", [<<"drain:", Rest/binary>> | _Args]}) ->
Id = drain_id(parse_id(Rest)),
Expand Down

0 comments on commit 868b8aa

Please sign in to comment.