stm-firehose 0.2.1 → 0.3.0
raw patch · 3 files changed
+20/−9 lines, 3 filesdep +resourcetdep +wai-conduitdep −network-conduitdep ~basedep ~blaze-builderdep ~conduitPVP ok
version bump matches the API change (PVP)
Dependencies added: resourcet, wai-conduit
Dependencies removed: network-conduit
Dependency ranges changed: base, blaze-builder, conduit, stm-conduit, transformers, wai, warp
API changes (from Hackage documentation)
Files
- Control/Concurrent/STM/Firehose.hs +1/−1
- Data/Conduit/Network/Firehose.hs +6/−5
- stm-firehose.cabal +13/−3
Control/Concurrent/STM/Firehose.hs view
@@ -25,7 +25,7 @@ -- | Sends a piece of data in the fire hose. writeEvent :: Firehose a -> a -> STM ()-writeEvent (Firehose lst) element = readTVar lst >>= mapM_ (flip tryWriteTBMQueue element)+writeEvent (Firehose lst) element = readTVar lst >>= mapM_ (`tryWriteTBMQueue` element) -- | Get a subscription from the fire hose, that will be used to -- read events.
Data/Conduit/Network/Firehose.hs view
@@ -12,13 +12,14 @@ import Control.Concurrent.STM import Control.Concurrent.STM.Firehose import Data.Conduit.TQueue+import Network.Wai.Conduit import qualified Data.Conduit.List as CL import Network.HTTP.Types-import Network.Wai import Data.Conduit import Blaze.ByteString.Builder import Network.Wai.Handler.Warp+import Data.Acquire import Control.Monad (void) import Control.Monad.IO.Class@@ -36,11 +37,11 @@ -> (a -> Builder) -- ^ The serialization function -> Firehose a -> Application-firehoseApp buffsize filtering serialize fh req = responseSourceBracket (atomically (subscribe buffsize fh)) (atomically . unsubscribe) runFirehose+firehoseApp buffsize filtering serialize fh req hdl = with subscription runFirehose where+ subscription = mkAcquire (atomically (subscribe buffsize fh)) (atomically . unsubscribe) filtering' = filtering req- -- Subscription a -> IO (Status, ResponseHeaders, Source IO (Flush Builder))- runFirehose sub = return (status200, [], sourceTBMQueue (getQueue sub) $= CL.filter filtering' $= CL.concatMap (\e -> [Chunk (serialize e), Flush]) )+ runFirehose sub = hdl $ responseSource status200 [] (sourceTBMQueue (getQueue sub) $= CL.filter filtering' $= CL.concatMap (\e -> [Chunk (serialize e), Flush]) ) {-| A fire hose conduit creator, that can be inserted in your conduits as firehose entry points. Will run Warp on the specified port. Please not@@ -54,6 +55,6 @@ -> IO (Conduit a m a) firehoseConduit port buffersize getFilter serialize = do fh <- atomically newFirehose- let settings = defaultSettings { settingsPort = port, settingsTimeout = 3600 }+ let settings = setPort port $ setTimeout 3600 defaultSettings void $ forkIO (runSettings settings (firehoseApp buffersize getFilter serialize fh)) return (CL.mapM (\m -> liftIO (atomically (writeEvent fh m)) >> return m))
stm-firehose.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: stm-firehose-version: 0.2.1+version: 0.3.0 synopsis: Conduits and STM operations for fire hoses. description: A fire hose is a component in a message passing system that let clients tap into the message flow. This module provides low level (built on STM channels) and high level (based on conduits) building blocks. It should work with a fixed amount of memory, and has non blocking write operations. license: BSD3@@ -25,8 +25,18 @@ ghc-options: -Wall -- other-modules: -- other-extensions: - build-depends: base >=4.6 && <4.8, stm >=2.4 && <2.5, stm-chans >=3.0 && <3.1, conduit >=1.0 && <1.2, network-conduit >=1.0 && <1.2, stm-conduit >=2.1 && <2.5, transformers >=0.3 && <0.4,- wai >= 2.0 && < 2.2, http-types == 0.8.*, blaze-builder == 0.3.*, warp >= 2.0 && < 2.2+ build-depends: base >=4.6 && <5+ , stm >=2.4 && <2.5+ , stm-chans >=3.0 && <3.1+ , conduit >=1.2 && <1.3+ , stm-conduit >=2.6 && <2.7+ , transformers >=0.4 && <0.5+ , wai >= 3.0 && < 3.1+ , http-types == 0.8.*+ , blaze-builder == 0.4.*+ , warp >= 3.1 && < 3.2+ , resourcet >= 1.1+ , wai-conduit == 3.* -- hs-source-dirs: default-language: Haskell2010