diff --git a/Network/Kafka/Producer.hs b/Network/Kafka/Producer.hs index dd87999..52109f0 100644 --- a/Network/Kafka/Producer.hs +++ b/Network/Kafka/Producer.hs @@ -85,9 +85,12 @@ send l ts = do withBrokerHandle broker $ \handle -> produce handle $ produceRequest requiredAcks requestTimeout ts getRandPartition :: Kafka m => Set PartitionAndLeader -> m (Maybe PartitionAndLeader) -getRandPartition ps = - liftIO $ (ps' ^?) . element <$> getStdRandom (randomR (0, length ps' - 1)) - where ps' = ps ^.. folded . filtered (has $ palLeader . leaderId . _Just) +getRandPartition ps = do + i <- liftIO (getStdRandom (randomR (0, length ps' - 1))) + + pure (snd <$> (ps' ^@? element i)) + + where ps' = ps ^.. folded . filtered (has $ palLeader . leaderId . _Just) -- * Messages diff --git a/milena.cabal b/milena.cabal index 30665ea..22cedb8 100644 --- a/milena.cabal +++ b/milena.cabal @@ -48,7 +48,7 @@ library , cereal >=0.4 && <0.6 , containers >=0.5 && <0.7 , digest >=0.0.1.0 && <0.1 - , lens >=4.4 && <4.20 + , lens >=5 && <6 , lifted-base >=0.2.3.6 && <0.3 , monad-control ==1.0.* , mtl >=2.1 && <2.3