improve message error handling (#286)

* message envelope sizes and protocol doc corrections

* change error handling in message delivery loop
This commit is contained in:
Evgeny Poberezkin
2022-01-12 10:36:22 +00:00
committed by GitHub
parent d1eba1ef2f
commit bfa4911217
6 changed files with 65 additions and 58 deletions
+4 -4
View File
@@ -108,10 +108,6 @@ instance Encoding SystemTime where
smpEncode = smpEncode . systemSeconds
smpP = MkSystemTime <$> smpP <*> pure 0
instance (Encoding a, Encoding b) => Encoding (a, b) where
smpEncode (a, b) = smpEncode a <> smpEncode b
smpP = (,) <$> smpP <*> smpP
-- lists encode/parse as a sequence of items prefixed with list length (as 1 byte)
smpEncodeList :: Encoding a => [a] -> ByteString
smpEncodeList xs = B.cons (lenEncode $ length xs) . B.concat $ map smpEncode xs
@@ -130,6 +126,10 @@ instance Encoding a => Encoding (L.NonEmpty a) where
0 -> fail "empty list"
n -> L.fromList <$> A.count n smpP
instance (Encoding a, Encoding b) => Encoding (a, b) where
smpEncode (a, b) = smpEncode a <> smpEncode b
smpP = (,) <$> smpP <*> smpP
instance (Encoding a, Encoding b, Encoding c) => Encoding (a, b, c) where
smpEncode (a, b, c) = smpEncode a <> smpEncode b <> smpEncode c
smpP = (,,) <$> smpP <*> smpP <*> smpP