module Control.Distributed.Process.Management.Internal.Trace.Remote
(
setTraceFlagsRemote
, startTraceRelay
, remoteTable
) where
import Control.Distributed.Process.Internal.Closure.BuiltIn
( cpEnableTraceRemote
)
import Control.Distributed.Process.Internal.Primitives
( getSelfPid
, relay
, nsendRemote
)
import Control.Distributed.Process.Management.Internal.Trace.Types
( TraceFlags(..)
, TraceOk(..)
)
import Control.Distributed.Process.Management.Internal.Trace.Primitives
( withRegisteredTracer
, enableTrace
)
import Control.Distributed.Process.Internal.Spawn
( spawn
)
import Control.Distributed.Process.Internal.Types
( Process
, ProcessId
, SendPort
, NodeId
)
import Control.Distributed.Static
( RemoteTable
, registerStatic
)
import Data.Rank1Dynamic (toDynamic)
remoteTable :: RemoteTable -> RemoteTable
remoteTable = registerStatic "$enableTraceRemote" (toDynamic enableTraceRemote)
enableTraceRemote :: ProcessId -> Process ()
enableTraceRemote pid =
getSelfPid >>= enableTrace >> relay pid
startTraceRelay :: NodeId -> Process ProcessId
startTraceRelay nodeId = do
withRegisteredTracer $ \pid ->
spawn nodeId $ cpEnableTraceRemote pid
setTraceFlagsRemote :: TraceFlags -> NodeId -> Process ()
setTraceFlagsRemote flags node = do
nsendRemote node
"trace.controller"
((Nothing :: Maybe (SendPort TraceOk)), flags)