Skip to content

Fix delivery callback (fallout from #161) #168

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

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion src/Kafka/Producer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ newProducer pps = liftIO $ do
tc <- topicConf (TopicProps $ (ppTopicProps pps))

-- add default delivery report callback
deliveryCallback (const mempty) kc
let Callback setCb = deliveryCallback (const mempty) in setCb kc

-- set callbacks
forM_ (ppCallbacks pps) (\(Callback setCb) -> setCb kc)
Expand Down
6 changes: 3 additions & 3 deletions src/Kafka/Producer/Callbacks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foreign.StablePtr (castPtrToStablePtr, deRefStablePtr, fre
import Kafka.Callbacks as X
import Kafka.Consumer.Types (Offset(..))
import Kafka.Internal.RdKafka (RdKafkaMessageT(..), RdKafkaRespErrT(..), rdKafkaConfSetDrMsgCb)
import Kafka.Internal.Setup (KafkaConf(..), getRdKafkaConf)
import Kafka.Internal.Setup (KafkaConf(..), getRdKafkaConf, Callback(..))
import Kafka.Internal.Shared (kafkaRespErr, readTopic, readKey, readPayload)
import Kafka.Producer.Types (ProducerRecord(..), DeliveryReport(..), ProducePartition(..))
import Kafka.Types (KafkaError(..), TopicName(..))
Expand All @@ -27,8 +27,8 @@ import Kafka.Types (KafkaError(..), TopicName(..))
-- callbacks. For callbacks to individual messsages see
-- 'Kafka.Producer.produceMessage\''./
--
deliveryCallback :: (DeliveryReport -> IO ()) -> KafkaConf -> IO ()
deliveryCallback callback kc = rdKafkaConfSetDrMsgCb (getRdKafkaConf kc) realCb
deliveryCallback :: (DeliveryReport -> IO ()) -> Callback
deliveryCallback callback = Callback $ \kc -> rdKafkaConfSetDrMsgCb (getRdKafkaConf kc) realCb
where
realCb :: t -> Ptr RdKafkaMessageT -> IO ()
realCb _ mptr =
Expand Down