git.iko.soy/distributed-process
on master help sign in
Merge pull request #182 from qnikst/queue-size-info
c7fb158Tim Watson
src/Control/Distributed/Process/Internal/Types.hs+1−1
@@ -542,7 +542,7 @@ data NodeStats = NodeStats {
542data ProcessInfo = ProcessInfo {
542data ProcessInfo = ProcessInfo {
543 infoNode :: NodeId
543 infoNode :: NodeId
544 , infoRegisteredNames :: [String]
544 , infoRegisteredNames :: [String]
545− , infoMessageQueueLength :: Maybe Int
545+ , infoMessageQueueLength :: Int
546 , infoMonitors :: [(ProcessId, MonitorRef)]
546 , infoMonitors :: [(ProcessId, MonitorRef)]
547 , infoLinks :: [ProcessId]
547 , infoLinks :: [ProcessId]
548 } deriving (Show, Eq, Typeable)
548 } deriving (Show, Eq, Typeable)
src/Control/Distributed/Process/Node.hs+4−3
@@ -88,6 +88,7 @@ import Control.Distributed.Process.Internal.CQueue
88 , enqueue
88 , enqueue
89 , newCQueue
89 , newCQueue
90 , mkWeakCQueue
90 , mkWeakCQueue
91+ , queueSize
91 )
92 )
92import qualified Network.Transport as NT
93import qualified Network.Transport as NT
93 ( Transport
94 ( Transport
@@ -974,10 +975,11 @@ ncEffectGetInfo from pid =
974 case mProc of
975 case mProc of
975 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
976 Nothing -> dispatch (isLocal node (ProcessIdentifier from))
976 from node (ProcessInfoNone DiedUnknownId)
977 from node (ProcessInfoNone DiedUnknownId)
977− Just _ -> do
978+ Just proc -> do
978 itsLinks <- gets (^. linksFor them)
979 itsLinks <- gets (^. linksFor them)
979 itsMons <- gets (^. monitorsFor them)
980 itsMons <- gets (^. monitorsFor them)
980 registered <- gets (^. registeredHere)
981 registered <- gets (^. registeredHere)
982+ size <- liftIO $ queueSize $ processQueue $ proc
981
983
982 let reg = registeredNames registered
984 let reg = registeredNames registered
983 dispatch (isLocal node (ProcessIdentifier from))
985 dispatch (isLocal node (ProcessIdentifier from))
@@ -986,8 +988,7 @@ ncEffectGetInfo from pid =
986 ProcessInfo {
988 ProcessInfo {
987 infoNode = (processNodeId pid)
989 infoNode = (processNodeId pid)
988 , infoRegisteredNames = reg
990 , infoRegisteredNames = reg
989− -- we cannot populate this field
990− , infoMessageQueueLength = Nothing
991+ , infoMessageQueueLength = size
991 , infoMonitors = Set.toList itsMons
992 , infoMonitors = Set.toList itsMons
992 , infoLinks = Set.toList itsLinks
993 , infoLinks = Set.toList itsLinks
993 }
994 }