diff --git a/src/Kafka/Admin.hs b/src/Kafka/Admin.hs index 9beb142..c21ab37 100644 --- a/src/Kafka/Admin.hs +++ b/src/Kafka/Admin.hs @@ -1,14 +1,26 @@ module Kafka.Admin where -import Control.Monad import Control.Monad.IO.Class +import Kafka.Internal.RdKafka +import Kafka.Internal.Setup + import Kafka.Types +import Kafka.Admin.AdminProperties + +data KAdmin = KAdmin { + adminKafka :: !Kafka + , adminKafkaConfig :: !KafkaConf +} -{- - -newKAdmin :: MonadIO m +newKAdmin :: MonadIO m => AdminProperties - -> m (Either KafkaError KafkaAdmin) - - - - -} + -> m (Either KafkaError KAdmin) +newKAdmin properties = liftIO $ do + kafkaConfig@(KafkaConf kafkaConf' _ _) <- kafkaConf ( KafkaProps $ adminProps properties) + maybeKafka <- newRdKafkaT RdKafkaProducer kafkaConf' + case maybeKafka of + Left err -> pure $ Left $ KafkaError err + Right kafka -> pure $ Right $ KAdmin (Kafka kafka) kafkaConfig +