Skip to content

Commit a027f75

Browse files
committed
Remove the monitoring agent as it's not required
1 parent a094396 commit a027f75

File tree

1 file changed

+2
-48
lines changed
  • src/Control/Distributed/Process

1 file changed

+2
-48
lines changed

src/Control/Distributed/Process/Node.hs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,8 @@ import Control.Distributed.Process.Internal.Types
186186
import 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
)
199192
import 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
365320
startServiceProcesses :: LocalNode -> IO ()
366321
startServiceProcesses 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

0 commit comments

Comments
 (0)