git.iko.soy/distributed-process
on master help sign in
Remove the monitoring agent as it's not required
commita027f7550e7a460ad27c6a342637e0dc37d6c11a authorTim Watson <watson.timothy@gmail.com> dateThu 15 Nov 2018, 13:02 (8 years ago) parenta094396
1 file changed+2−48
src/Control/Distributed/Process/Node.hs+2−48
src/Control/Distributed/Process/Node.hs+2−48
@@ -186,15 +186,8 @@ import Control.Distributed.Process.Internal.Types
186186import Control.Distributed.Process.Management.Internal.Agent
187187 ( mxAgentController
188188 )
189−import Control.Distributed.Process.Management
190− ( mxAgent
191− , mxSink
192− , liftMX
193− , mxUpdateLocal
194− , mxGetLocal
195− , mxReady
196− , MxEvent(..)
197− , MxAgentId(..)
189+import Control.Distributed.Process.Management.Internal.Types
190+ ( MxEvent(..)
198191 )
199192import qualified Control.Distributed.Process.Management.Internal.Trace.Remote as Trace
200193 ( remoteTable
@@ -323,44 +316,6 @@ startDefaultTracer node' = do
323316
324317-- TODO: we need a better mechanism for defining and registering services
325318
326−{- note [registry monitoring agent]
327− This agent listens for 'MxRegistered' and 'MxUnRegistered' events and tracks
328− all labels for remote 'ProcessId's that are stored in the registry.
329−
330− When a remote process is registered, the agent starts monitoring it until it
331− is unregistered. We can safely ignore ProcessMonitorNotification's, since the
332− node controller is obligated to issue an MxUnRegistered event for any labels
333− connected to a dead process. Thus, our only responsibility here is to ensure
334− that we set up monitors for locally registered processes, and tear them down
335− once unregistration occurs.
336− -}
337−
338−registryMonitorAgent :: Process ProcessId
339−registryMonitorAgent = do
340− nid <- getSelfNode
341− mxAgent registryMonitorAgentId (Map.empty :: Map String MonitorRef)
342− [ mxSink $ \ev -> do
343− case ev of
344− MxRegistered pid label
345− | processNodeId pid /= nid -> do
346− mref <- liftMX $ monitor pid
347− mxUpdateLocal (Map.insert label mref)
348− MxUnRegistered pid label
349− | processNodeId pid /= nid -> do
350− mrefs <- mxGetLocal
351− forM_ (label `Map.lookup` mrefs) $ \mref -> do
352− liftMX $ unmonitorAsync mref
353− mxUpdateLocal (Map.delete label)
354− _ -> return ()
355− mxReady
356− -- [note: no need to remove async answers from mailbox]
357− -- The framework simply discards any input you don't have a handler for.
358− -- See Management.hs `runAgent` for details.
359− ]
360− where
361− registryMonitorAgentId :: MxAgentId
362− registryMonitorAgentId = MxAgentId "service.registry.monitoring"
363−
364319-- | Start and register the service processes on a node
365320startServiceProcesses :: LocalNode -> IO ()
366321startServiceProcesses node = do
@@ -376,7 +331,6 @@ startServiceProcesses node = do
376331 -- loops during tracing if the user reregisters the "logger" with a custom
377332 -- process which uses 'send' or other primitives which are traced.
378333 register "trace.logger" logger
379− void $ registryMonitorAgent
380334 where
381335 loop = do
382336 receiveWait