Skip to content

Commit

Permalink
hstream-kafka-client: init
Browse files Browse the repository at this point in the history
  • Loading branch information
alissa-tung committed Sep 28, 2023
1 parent 64f9eb2 commit c35d1f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hstream-kafka/client/HStream/Kafka/Client/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ recvByteString sock = do
recvResp :: forall a. K.Serializable a => NW.Socket -> IO a
recvResp sock = do
bs <- recvByteString sock
ret <- K.runParser @K.ResponseHeader K.get bs
ret <- K.runParser K.getResponseHeaderV0 bs
(l, header) <- case ret of
K.Done l header -> pure (l, header)
K.More k -> undefined
Expand Down
18 changes: 12 additions & 6 deletions hstream-kafka/protocol/Kafka/Protocol/Message.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Kafka.Protocol.Message
( RequestHeader (..)
, ResponseHeader (..)
, getResponseHeaderV0
, getResponseHeaderV1
, putResponseHeader
, runPutResponseHeaderLazy
, Unsupported (..)
Expand Down Expand Up @@ -62,13 +64,17 @@ data ResponseHeader = ResponseHeader
, responseTaggedFields :: !(Either Unsupported TaggedFields)
} deriving (Show, Eq)

instance Serializable ResponseHeader where
get = do
responseCorrelationId <- get
responseTaggedFields <- pure $ Left Unsupported -- FIXME
pure ResponseHeader{..}
getResponseHeaderV0 :: Parser ResponseHeader
getResponseHeaderV0 = do
responseCorrelationId <- get
responseTaggedFields <- pure $ Left Unsupported
pure ResponseHeader{..}

put = putResponseHeader
getResponseHeaderV1 :: Parser ResponseHeader
getResponseHeaderV1 = do
responseCorrelationId <- get
responseTaggedFields <- getEither True
pure ResponseHeader{..}

putResponseHeader :: ResponseHeader -> Builder
putResponseHeader ResponseHeader{..} =
Expand Down

0 comments on commit c35d1f9

Please sign in to comment.