@@ -14,6 +14,7 @@ module Control.Distributed.Process.Internal.Types
14
14
, nullProcessId
15
15
-- * Local nodes and processes
16
16
, LocalNode (.. )
17
+ , Tracer (.. )
17
18
, LocalNodeState (.. )
18
19
, LocalProcess (.. )
19
20
, LocalProcessState (.. )
@@ -90,6 +91,7 @@ import Control.Exception (Exception)
90
91
import Control.Concurrent (ThreadId )
91
92
import Control.Concurrent.Chan (Chan )
92
93
import Control.Concurrent.STM (STM )
94
+ import qualified Control.Concurrent.STM as STM (TQueue )
93
95
import qualified Network.Transport as NT (EndPoint , EndPointAddress , Connection )
94
96
import Control.Applicative (Applicative , Alternative , (<$>) , (<*>) )
95
97
import Control.Monad.Reader (MonadReader (.. ), ReaderT , runReaderT )
@@ -177,19 +179,26 @@ nullProcessId nid =
177
179
-- Local nodes and processes --
178
180
--------------------------------------------------------------------------------
179
181
182
+ -- | Required for system tracing in the node controller
183
+ data Tracer =
184
+ LogFileTracer ThreadId (STM. TQueue String )
185
+ | EventLogTracer (String -> IO () )
186
+
180
187
-- | Local nodes
181
188
data LocalNode = LocalNode
182
189
{ -- | 'NodeId' of the node
183
- localNodeId :: ! NodeId
190
+ localNodeId :: ! NodeId
184
191
-- | The network endpoint associated with this node
185
- , localEndPoint :: ! NT. EndPoint
192
+ , localEndPoint :: ! NT. EndPoint
186
193
-- | Local node state
187
- , localState :: ! (StrictMVar LocalNodeState )
194
+ , localState :: ! (StrictMVar LocalNodeState )
188
195
-- | Channel for the node controller
189
- , localCtrlChan :: ! (Chan NCMsg )
196
+ , localCtrlChan :: ! (Chan NCMsg )
197
+ -- | Current active system debug/trace log
198
+ , localTracer :: ! Tracer
190
199
-- | Runtime lookup table for supporting closures
191
200
-- TODO: this should be part of the CH state, not the local endpoint state
192
- , remoteTable :: ! RemoteTable
201
+ , remoteTable :: ! RemoteTable
193
202
}
194
203
195
204
data ImplicitReconnect = WithImplicitReconnect | NoImplicitReconnect
@@ -434,7 +443,7 @@ data WhereIsReply = WhereIsReply String (Maybe ProcessId)
434
443
data RegisterReply = RegisterReply String Bool
435
444
deriving (Show , Typeable )
436
445
437
- -- | Provide information about a running process
446
+ -- | Provide information about a running process
438
447
data ProcessInfo = ProcessInfo {
439
448
infoNode :: NodeId
440
449
, infoRegisteredNames :: [String ]
@@ -443,21 +452,9 @@ data ProcessInfo = ProcessInfo {
443
452
, infoLinks :: [ProcessId ]
444
453
} deriving (Show , Eq , Typeable )
445
454
446
- instance Binary ProcessInfo where
447
- get = ProcessInfo <$> get <*> get <*> get <*> get <*> get
448
- put pInfo = put (infoNode pInfo)
449
- >> put (infoRegisteredNames pInfo)
450
- >> put (infoMessageQueueLength pInfo)
451
- >> put (infoMonitors pInfo)
452
- >> put (infoLinks pInfo)
453
-
454
455
data ProcessInfoNone = ProcessInfoNone DiedReason
455
456
deriving (Show , Typeable )
456
457
457
- instance Binary ProcessInfoNone where
458
- get = ProcessInfoNone <$> get
459
- put (ProcessInfoNone r) = put r
460
-
461
458
--------------------------------------------------------------------------------
462
459
-- Node controller internal data types --
463
460
--------------------------------------------------------------------------------
@@ -533,16 +530,16 @@ instance Binary ProcessSignal where
533
530
get = do
534
531
header <- getWord8
535
532
case header of
536
- 0 -> Link <$> get
537
- 1 -> Unlink <$> get
538
- 2 -> Monitor <$> get
539
- 3 -> Unmonitor <$> get
540
- 4 -> Died <$> get <*> get
541
- 5 -> Spawn <$> get <*> get
542
- 6 -> WhereIs <$> get
543
- 7 -> Register <$> get <*> get <*> get <*> get
544
- 8 -> NamedSend <$> get <*> (payloadToMessage <$> get)
545
- 9 -> Kill <$> get <*> get
533
+ 0 -> Link <$> get
534
+ 1 -> Unlink <$> get
535
+ 2 -> Monitor <$> get
536
+ 3 -> Unmonitor <$> get
537
+ 4 -> Died <$> get <*> get
538
+ 5 -> Spawn <$> get <*> get
539
+ 6 -> WhereIs <$> get
540
+ 7 -> Register <$> get <*> get <*> get <*> get
541
+ 8 -> NamedSend <$> get <*> (payloadToMessage <$> get)
542
+ 9 -> Kill <$> get <*> get
546
543
10 -> Exit <$> get <*> (payloadToMessage <$> get)
547
544
30 -> GetInfo <$> get
548
545
_ -> fail " ProcessSignal.get: invalid"
@@ -591,6 +588,18 @@ instance Binary RegisterReply where
591
588
put (RegisterReply label ok) = put label >> put ok
592
589
get = RegisterReply <$> get <*> get
593
590
591
+ instance Binary ProcessInfo where
592
+ get = ProcessInfo <$> get <*> get <*> get <*> get <*> get
593
+ put pInfo = put (infoNode pInfo)
594
+ >> put (infoRegisteredNames pInfo)
595
+ >> put (infoMessageQueueLength pInfo)
596
+ >> put (infoMonitors pInfo)
597
+ >> put (infoLinks pInfo)
598
+
599
+ instance Binary ProcessInfoNone where
600
+ get = ProcessInfoNone <$> get
601
+ put (ProcessInfoNone r) = put r
602
+
594
603
--------------------------------------------------------------------------------
595
604
-- Accessors --
596
605
--------------------------------------------------------------------------------
0 commit comments