Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hstream-kafka: add debugging log for request and response #1611

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hstream-kafka/src/Kafka/Protocol/Encoding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ newtype CompactKaArray a = CompactKaArray
{ unCompactKaArray :: Maybe (Vector a) }
deriving newtype (Show, Eq, Ord)

newtype RecordBytes = RecordBytes (Maybe ByteString)

newtype RecordKey = RecordKey { unRecordKey :: Maybe ByteString }
deriving newtype (Show, Eq, Ord)

Expand Down
8 changes: 5 additions & 3 deletions hstream-kafka/src/Kafka/Protocol/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ type UnaryHandler i o = RequestContext -> i -> IO o

data RpcHandler where
UnaryHandler
:: (Serializable i, Serializable o) => UnaryHandler i o -> RpcHandler
:: ( Serializable i, Serializable o
, Show i, Show o
) => UnaryHandler i o -> RpcHandler

instance Show RpcHandler where
show (UnaryHandler _) = "<UnaryHandler>"
Expand All @@ -54,8 +56,8 @@ data ServiceHandler = ServiceHandler
} deriving (Show)

hd :: ( HasMethod s m
, Serializable i
, Serializable o
, Serializable i, Serializable o
, Show i, Show o
, MethodInput s m ~ i
, MethodOutput s m ~ o
)
Expand Down
3 changes: 3 additions & 0 deletions hstream-kafka/src/Kafka/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import qualified Network.Socket as N
import qualified Network.Socket.ByteString as N
import qualified Network.Socket.ByteString.Lazy as NL

import qualified HStream.Logger as Log
import Kafka.Protocol.Encoding
import Kafka.Protocol.Message
import Kafka.Protocol.Service
Expand Down Expand Up @@ -68,7 +69,9 @@ runServer ServerOptions{..} handlers =
case rpcHandler of
UnaryHandler rpcHandler' -> do
req <- runGet l
Log.debug $ "Received request: " <> Log.buildString' req
resp <- rpcHandler' RequestContext req
Log.debug $ "Server response: " <> Log.buildString' resp
let respBs = runPutLazy resp
(_, respHeaderVer) = getHeaderVersion requestApiKey requestApiVersion
respHeaderBs =
Expand Down
2 changes: 0 additions & 2 deletions hstream/src/HStream/Server/KafkaHandler/Produce.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ handleProduceV2
-> K.ProduceRequestV2
-> IO K.ProduceResponseV2
handleProduceV2 ServerContext{..} _ [email protected]{..} = do
Log.debug $ Log.buildString $ "received request " <> show req

-- TODO: handle request args: acks, timeoutMs

let topicData' = fromMaybe V.empty (K.unKaArray topicData)
Expand Down