-
-
Save itkovian/3e990d0b29818984418f7767b157ca18 to your computer and use it in GitHub Desktop.
messageSink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
messageSink success failure messageCount frequency = loop | |
where | |
loop = do | |
v <- await | |
case v of | |
Just n -> case n of | |
Right json -> do | |
Data.Conduit.yield (encodeNormalisedRsyslog json) $$ success | |
Data.Conduit.yield (SBS.pack "\n") $$ success | |
liftIO $ increaseCount (1, 0) messageCount frequency | |
loop | |
Left l -> do | |
Data.Conduit.yield l $$ failure | |
Data.Conduit.yield (SBS.pack "\n") $$ failure | |
liftIO $ increaseCount (0, 1) messageCount frequency | |
loop | |
Nothing -> return () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment