Permalink
Browse files

Add convenience functions to obtain drains by type

  • Loading branch information...
1 parent 3386377 commit eaa600f6e8d92d5c9196a6f1522e545645ae6786 @ferd ferd committed Nov 11, 2013
Showing with 11 additions and 0 deletions.
  1. +11 −0 src/logplex_drain.erl
View
@@ -62,6 +62,8 @@
]).
-export([by_dest/0
+ ,by_type/0
+ ,by_type/1
,num_drains/0
,pids/0
,ids/0
@@ -310,6 +312,7 @@ lookup_by_channel(ChannelId) when is_integer(ChannelId) ->
object()
end)).
+
-spec register(id(), logplex_channel:id(), atom(), term()) -> ok.
register(DrainId, ChannelId, Type, Dest)
when is_integer(DrainId), is_integer(ChannelId) ->
@@ -350,6 +353,14 @@ uri_to_binary(#ex_uri{} = Uri) ->
by_dest() ->
gproc:lookup_local_properties(drain_dest).
+by_type() ->
+ gproc:lookup_local_properties(drain_type).
+
+by_type(http) ->
+ [Pid || {Pid, http} <- gproc:lookup_local_properties(drain_type)];
+by_type(tcpsyslog) ->
+ [Pid || {Pid, tcpsyslog} <- gproc:lookup_local_properties(drain_type)].
+
-spec num_drains() -> non_neg_integer().
num_drains() ->
gproc:select_count({l, n},

0 comments on commit eaa600f

Please sign in to comment.