-module(tpTracerPool).
|
|
-behaviour(supervisor).
|
|
|
|
-export([
|
|
start_link/3
|
|
, init/1
|
|
, tracers/1
|
|
]).
|
|
|
|
start_link(NumTracers, TracerMod, Opts) ->
|
|
supervisor:start_link(?MODULE, [NumTracers, TracerMod, Opts]).
|
|
|
|
init([NumTracers, TracerMod, Opts]) ->
|
|
ChildSpecs = [
|
|
#{
|
|
id => {tracer, Index},
|
|
start => {TracerMod, start_link, [Index, Opts]},
|
|
restart => temporary
|
|
} || Index <- lists:seq(1, NumTracers)
|
|
],
|
|
SupFlags = #{strategy => one_for_all, intensity => 5, period => 10},
|
|
{ok, {SupFlags, ChildSpecs}}.
|
|
|
|
tracers(PoolPid) ->
|
|
[Pid || {_, Pid, _, _} <- supervisor:which_children(PoolPid)].
|