mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 01:41:37 +03:00
Validate event parsing.
This commit is contained in:
parent
efc6103fc1
commit
131cb30900
@ -49,6 +49,13 @@ data Bug
|
|||||||
| CollectAllFX
|
| CollectAllFX
|
||||||
{ bPierPath :: FilePath
|
{ bPierPath :: FilePath
|
||||||
}
|
}
|
||||||
|
| ValidateEvents
|
||||||
|
{ bPierPath :: FilePath
|
||||||
|
, bFirstEvt :: Word64
|
||||||
|
}
|
||||||
|
| ValidateFX
|
||||||
|
{ bPierPath :: FilePath
|
||||||
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
data Cmd
|
data Cmd
|
||||||
@ -209,6 +216,17 @@ valPill = do
|
|||||||
|
|
||||||
pure ValidatePill{..}
|
pure ValidatePill{..}
|
||||||
|
|
||||||
|
checkEvs :: Parser Bug
|
||||||
|
checkEvs = do
|
||||||
|
bPierPath <- strArgument (metavar "PIER" <> help "Path to pier")
|
||||||
|
|
||||||
|
bFirstEvt <- option auto $ long "start"
|
||||||
|
<> metavar "FST"
|
||||||
|
<> help "starting from event FST"
|
||||||
|
<> value 1
|
||||||
|
|
||||||
|
pure ValidateEvents{..}
|
||||||
|
|
||||||
bugCmd :: Parser Cmd
|
bugCmd :: Parser Cmd
|
||||||
bugCmd = fmap CmdBug
|
bugCmd = fmap CmdBug
|
||||||
$ subparser
|
$ subparser
|
||||||
@ -220,6 +238,10 @@ bugCmd = fmap CmdBug
|
|||||||
( info (allFx <**> helper)
|
( info (allFx <**> helper)
|
||||||
$ progDesc "Replay entire event log, collecting all effects"
|
$ progDesc "Replay entire event log, collecting all effects"
|
||||||
)
|
)
|
||||||
|
<> command "validate-events"
|
||||||
|
( info (checkEvs <**> helper)
|
||||||
|
$ progDesc "Parse all data in event log"
|
||||||
|
)
|
||||||
|
|
||||||
allFx :: Parser Bug
|
allFx :: Parser Bug
|
||||||
allFx = do
|
allFx = do
|
||||||
|
@ -195,8 +195,8 @@ tryFullReplay shipPath = do
|
|||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
tryParseEvents :: FilePath -> EventId -> IO ()
|
checkEvs :: FilePath -> Word64 -> IO ()
|
||||||
tryParseEvents dir first = do
|
checkEvs pier first = do
|
||||||
vPax <- newIORef []
|
vPax <- newIORef []
|
||||||
with (Log.existing dir) $ \log -> do
|
with (Log.existing dir) $ \log -> do
|
||||||
let ident = Log.identity log
|
let ident = Log.identity log
|
||||||
@ -206,16 +206,20 @@ tryParseEvents dir first = do
|
|||||||
paths <- sort . ordNub <$> readIORef vPax
|
paths <- sort . ordNub <$> readIORef vPax
|
||||||
for_ paths print
|
for_ paths print
|
||||||
where
|
where
|
||||||
|
dir :: FilePath
|
||||||
|
dir = pier <> "/.urb/log"
|
||||||
|
|
||||||
showEvents :: IORef [Path] -> EventId -> EventId
|
showEvents :: IORef [Path] -> EventId -> EventId
|
||||||
-> ConduitT ByteString Void IO ()
|
-> ConduitT ByteString Void IO ()
|
||||||
showEvents vPax eId cycle = await >>= \case
|
showEvents vPax eId cycle = await >>= \case
|
||||||
Nothing -> print "Done!"
|
Nothing -> print "Everything checks out."
|
||||||
Just bs -> do
|
Just bs -> do
|
||||||
-- print ("got event", eId)
|
-- print ("got event", eId)
|
||||||
n <- liftIO $ cueBSExn bs
|
n <- liftIO $ cueBSExn bs
|
||||||
-- print ("done cue", eId)
|
-- print ("done cue", eId)
|
||||||
when (eId <= cycle) $ do
|
when (eId <= cycle) $ do
|
||||||
putStrLn ("[tryParseEvents] lifecycle nock: " <> tshow eId)
|
-- putStrLn ("[tryParseEvents] lifecycle nock: " <> tshow eId)
|
||||||
|
pure ()
|
||||||
when (eId > cycle) $ liftIO $ do
|
when (eId > cycle) $ liftIO $ do
|
||||||
(mug, wen, evNoun) <- unpackJob n
|
(mug, wen, evNoun) <- unpackJob n
|
||||||
case fromNounErr evNoun of
|
case fromNounErr evNoun of
|
||||||
@ -361,6 +365,8 @@ main = CLI.parseArgs >>= \case
|
|||||||
CLI.CmdNew n o -> newShip n o
|
CLI.CmdNew n o -> newShip n o
|
||||||
CLI.CmdBug (CLI.CollectAllFX pax) -> collectAllFx pax
|
CLI.CmdBug (CLI.CollectAllFX pax) -> collectAllFx pax
|
||||||
CLI.CmdBug (CLI.ValidatePill pax pil seq) -> testPill pax pil seq
|
CLI.CmdBug (CLI.ValidatePill pax pil seq) -> testPill pax pil seq
|
||||||
|
CLI.CmdBug (CLI.ValidateFX pax) -> print "validate-fx"
|
||||||
|
CLI.CmdBug (CLI.ValidateEvents pax start) -> checkEvs pax start
|
||||||
|
|
||||||
validatePill :: FilePath -> IO ()
|
validatePill :: FilePath -> IO ()
|
||||||
validatePill = const (pure ())
|
validatePill = const (pure ())
|
||||||
|
Loading…
Reference in New Issue
Block a user