diff options
author | Will Thompson <will@willthompson.co.uk> | 2017-07-26 09:28:04 +0100 |
---|---|---|
committer | Will Thompson <will@willthompson.co.uk> | 2017-07-26 10:11:43 +0100 |
commit | 980131368f021e851cbee62f1a49d7bd2e80ece6 (patch) | |
tree | 9700f6a4485b8f54a9947dbdf389fd0ae6dd6a4d | |
parent | 883a3d311d837a5175f5623c48dcc2acbafe3f71 (diff) |
Simplify 'Detailed' type
Since dropping the plaintext log format, we always have access to the
full message body & size.
-rw-r--r-- | Bustle/Loader/Pcap.hs | 4 | ||||
-rw-r--r-- | Bustle/Renderer.hs | 2 | ||||
-rw-r--r-- | Bustle/Stats.hs | 14 | ||||
-rw-r--r-- | Bustle/Types.hs | 11 | ||||
-rw-r--r-- | Bustle/UI/DetailsView.hs | 9 |
5 files changed, 19 insertions, 21 deletions
diff --git a/Bustle/Loader/Pcap.hs b/Bustle/Loader/Pcap.hs index f59e902..67efaa9 100644 --- a/Bustle/Loader/Pcap.hs +++ b/Bustle/Loader/Pcap.hs @@ -156,7 +156,7 @@ bustlify :: Monad m -> StateT PendingMessages m B.DetailedEvent bustlify µs bytes m = do bm <- buildBustledMessage - return $ B.Detailed µs bm (Just (bytes, m)) + return $ B.Detailed µs bm bytes m where sender = receivedMessageSender m -- FIXME: can we do away with the un-Maybe-ing and just push that Nothing @@ -173,7 +173,7 @@ bustlify µs bytes m = do } -- FIXME: we shouldn't need to construct almost the same thing here -- and 10 lines above maybe? - insertPending sender serial mc (B.Detailed µs call (Just (bytes, m))) + insertPending sender serial mc (B.Detailed µs call bytes m) return $ B.MessageEvent call (ReceivedMethodReturn _serial mr) -> do diff --git a/Bustle/Renderer.hs b/Bustle/Renderer.hs index 8b9de33..dc05bc4 100644 --- a/Bustle/Renderer.hs +++ b/Bustle/Renderer.hs @@ -664,7 +664,7 @@ processOne bus de = case deEvent de of processMessage :: Bus -> Detailed Message -> Renderer () -processMessage bus dm@(Detailed _ m _) = do +processMessage bus dm@(Detailed _ m _ _) = do orly <- shouldShow bus m when orly $ case m of Signal {} -> do diff --git a/Bustle/Stats.hs b/Bustle/Stats.hs index e69cc27..3ac8ce2 100644 --- a/Bustle/Stats.hs +++ b/Bustle/Stats.hs @@ -45,8 +45,8 @@ data TallyType = TallyMethod | TallySignal repr :: DetailedEvent -> Maybe (TallyType, Maybe InterfaceName, MemberName) -repr (Detailed _ (NOCEvent _) _) = Nothing -repr (Detailed _ (MessageEvent msg) _) = +repr (Detailed _ (NOCEvent _) _ _) = Nothing +repr (Detailed _ (MessageEvent msg) _ _) = case msg of MethodCall { member = m } -> Just (TallyMethod, iface m, membername m) Signal { member = m } -> Just (TallySignal, iface m, membername m) @@ -109,7 +109,7 @@ methodTimes = reverse methodReturn dm = do let m = deEvent dm guard (isReturn m) - Detailed start (call@(MethodCall {})) _ <- inReplyTo m + Detailed start (call@(MethodCall {})) _ _ <- inReplyTo m return ( iface (member call) , membername (member call) , deTimestamp dm - start @@ -159,14 +159,14 @@ messageSizes messages = f :: Detailed Message -> Map (SizeType, Maybe InterfaceName, MemberName) [Int] -> Map (SizeType, Maybe InterfaceName, MemberName) [Int] - f dm = case (sizeKeyRepr dm, deDetails dm) of - (Just key, Just (size, _)) -> Map.insertWith' (++) key [size] - _ -> id + f dm = case sizeKeyRepr dm of + Just key -> Map.insertWith' (++) key [deMessageSize dm] + _ -> id callDetails :: Message -> Maybe (Maybe InterfaceName, MemberName) callDetails msg = do - Detailed _ msg' _ <- inReplyTo msg + Detailed _ msg' _ _ <- inReplyTo msg return (iface (member msg'), membername (member msg')) sizeKeyRepr :: Detailed Message diff --git a/Bustle/Types.hs b/Bustle/Types.hs index 1ddc5bb..fd34e29 100644 --- a/Bustle/Types.hs +++ b/Bustle/Types.hs @@ -165,14 +165,15 @@ type MessageSize = Int data Detailed e = Detailed { deTimestamp :: Microseconds , deEvent :: e - , deDetails :: Maybe (MessageSize, ReceivedMessage) + , deMessageSize :: MessageSize + , deReceivedMessage :: ReceivedMessage } deriving (Show, Eq, Functor) type DetailedEvent = Detailed Event instance Ord e => Ord (Detailed e) where - compare (Detailed µs x _) (Detailed µs' y _) + compare (Detailed µs x _ _) (Detailed µs' y _ _) = compare (µs, x) (µs', y) data Change = Claimed UniqueName @@ -184,10 +185,10 @@ partitionDetaileds :: [DetailedEvent] -> ([Detailed NOC], [Detailed Message]) partitionDetaileds = partitionEithers . map f where - f (Detailed µs e details) = + f (Detailed µs e size rm) = case e of - NOCEvent n -> Left $ Detailed µs n details - MessageEvent m -> Right $ Detailed µs m details + NOCEvent n -> Left $ Detailed µs n size rm + MessageEvent m -> Right $ Detailed µs m size rm mentionedNames :: Message -> [TaggedBusName] mentionedNames m = sender m:dest diff --git a/Bustle/UI/DetailsView.hs b/Bustle/UI/DetailsView.hs index c347bbd..f164da6 100644 --- a/Bustle/UI/DetailsView.hs +++ b/Bustle/UI/DetailsView.hs @@ -100,7 +100,7 @@ detailsViewNew = do return $ DetailsView table title pathLabel memberLabel view pickTitle :: Detailed Message -> Marquee -pickTitle (Detailed _ m _) = case m of +pickTitle (Detailed _ m _ _) = case m of MethodCall {} -> b (escape (__ "Method call")) MethodReturn {} -> b (escape (__ "Method return")) Error {} -> b (escape (__ "Error")) @@ -114,7 +114,7 @@ getMemberMarkup m = toPangoMarkup $ formatMember (iface m) (membername m) getMember :: Detailed Message -> Maybe Member -getMember (Detailed _ m _) = case m of +getMember (Detailed _ m _ _) = case m of MethodCall {} -> Just $ member m Signal {} -> Just $ member m MethodReturn {} -> callMember @@ -123,10 +123,7 @@ getMember (Detailed _ m _) = case m of callMember = fmap (member . deEvent) $ inReplyTo m formatMessage :: Detailed Message -> String -formatMessage (Detailed _ _ Nothing) = - __ "No message body information is available. Please capture a fresh log \ - \using a recent version of Bustle!" -formatMessage (Detailed _ _ (Just (_size, rm))) = +formatMessage (Detailed _ _ _ rm) = formatArgs $ D.receivedMessageBody rm where formatArgs = intercalate "\n" . map (format_Variant VariantStyleSignature) |