git.iko.soy/distributed-process
on remove-table-api help sign in
61 lines 1.7 kB history raw
1module Control.Distributed.Process.Management.Internal.Trace.Remote
2 ( -- * Configuring A Remote Tracer
3 setTraceFlagsRemote
4 , startTraceRelay
5 -- * Remote Table
6 , remoteTable
7 ) where
9import Control.Distributed.Process.Internal.Closure.BuiltIn
10 ( cpEnableTraceRemote
11 )
12import Control.Distributed.Process.Internal.Primitives
13 ( getSelfPid
14 , relay
15 , nsendRemote
16 )
17import Control.Distributed.Process.Management.Internal.Trace.Types
18 ( TraceFlags(..)
19 , TraceOk(..)
20 )
21import Control.Distributed.Process.Management.Internal.Trace.Primitives
22 ( withRegisteredTracer
23 , enableTrace
24 )
25import Control.Distributed.Process.Internal.Spawn
26 ( spawn
27 )
28import Control.Distributed.Process.Internal.Types
29 ( Process
30 , ProcessId
31 , SendPort
32 , NodeId
33 )
34import Control.Distributed.Static
35 ( RemoteTable
36 , registerStatic
37 )
38import Data.Rank1Dynamic (toDynamic)
40-- | Remote Table.
41remoteTable :: RemoteTable -> RemoteTable
42remoteTable = registerStatic "$enableTraceRemote" (toDynamic enableTraceRemote)
44enableTraceRemote :: ProcessId -> Process ()
45enableTraceRemote pid =
46 getSelfPid >>= enableTrace >> relay pid
48-- | Starts a /trace relay/ process on the remote node, which forwards all trace
49-- events to the registered tracer on /this/ (the calling process') node.
50startTraceRelay :: NodeId -> Process ProcessId
51startTraceRelay nodeId = do
52 withRegisteredTracer $ \pid ->
53 spawn nodeId $ cpEnableTraceRemote pid
55-- | Set the given flags for a remote node (asynchronous).
56setTraceFlagsRemote :: TraceFlags -> NodeId -> Process ()
57setTraceFlagsRemote flags node = do
58 nsendRemote node
59 "trace.controller"
60 ((Nothing :: Maybe (SendPort TraceOk)), flags)