diff --git a/Control/Concurrent/STM/Firehose.hs b/Control/Concurrent/STM/Firehose.hs
new file mode 100644
--- /dev/null
+++ b/Control/Concurrent/STM/Firehose.hs
@@ -0,0 +1,45 @@
+module Control.Concurrent.STM.Firehose (Firehose, Subscription, newFirehose, writeEvent, subscribe, unsubscribe, readEvent, getQueue) where
+
+import Control.Concurrent.STM
+import Control.Concurrent.STM.TBMQueue
+import Control.Monad (filterM)
+
+newtype Firehose a = Firehose (TVar [TBMQueue a])
+
+data Subscription a = Subscription (TBMQueue a) (Firehose a)
+
+-- | Creates a new 'Firehose' item.
+newFirehose :: STM (Firehose a)
+newFirehose = Firehose `fmap` newTVar []
+
+-- | Sends a piece of data in the fire hose.
+writeEvent :: Firehose a -> a -> STM ()
+writeEvent (Firehose lst) element = readTVar lst >>= mapM_ (flip tryWriteTBMQueue element)
+
+-- | Get a subscription from the fire hose, that will be used to
+-- read events.
+subscribe :: Int -- ^ Number of elements buffered. If set too high, it will increase memory usage. If set too low, activity spikes will result in message loss.
+          -> Firehose a -> STM (Subscription a)
+subscribe len f@(Firehose lst) = do
+    nq <- newTBMQueue len
+    modifyTVar' lst (nq:)
+    return (Subscription nq f)
+
+-- | Unsubscribe from the fire hose. Subsequent calls to 'readEvent' will
+-- return 'Nothing'. This runs in O(n), where n is the current number of
+-- subscriptions.
+unsubscribe :: Subscription a -> STM ()
+unsubscribe (Subscription q (Firehose lst)) = do
+    closeTBMQueue q
+    queues <- readTVar lst
+    nqueues <- filterM (fmap not . isClosedTBMQueue) queues
+    writeTVar lst nqueues
+
+-- | Read an event from a 'Subscription'. This will return 'Nothing' if the
+-- firehose is shut, or the subscription removed.
+readEvent :: Subscription a -> STM (Maybe a)
+readEvent (Subscription q _) = readTBMQueue q
+
+-- | Gets the underlying queue from a subscription.
+getQueue :: Subscription a -> TBMQueue a
+getQueue (Subscription q _) = q
diff --git a/Data/Conduit/Network/Firehose.hs b/Data/Conduit/Network/Firehose.hs
new file mode 100644
--- /dev/null
+++ b/Data/Conduit/Network/Firehose.hs
@@ -0,0 +1,43 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Data.Conduit.Network.Firehose (firehoseApp, firehoseConduit) where
+
+import Control.Concurrent (forkIO)
+import Control.Concurrent.STM
+import Control.Concurrent.STM.Firehose
+import Data.Conduit.TQueue
+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 Control.Monad (void)
+import Control.Monad.IO.Class
+
+-- | A firehose application, suitable for use in a wai-compatible server.
+firehoseApp :: Int -- ^ Buffer size for the fire hose threads
+            -> (Request -> a ->  Bool) -- ^ A filtering function for fire hose messages. Only messages that match this functions will be passed. The request can be used to build the filter.
+            -> (a -> Builder) -- ^ The serialization function
+            -> Firehose a
+            -> Application
+firehoseApp buffsize filtering serialize fh req = responseSourceBracket (atomically (subscribe buffsize fh)) (atomically . unsubscribe) runFirehose
+    where
+        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]) )
+
+-- | A fire hose conduit creator, that can be inserted in your conduits as
+-- firehose entry points. Will run Warp on the specified port.
+firehoseConduit :: (Monad m, MonadIO m)
+                => Int -- ^ Port to listen on
+                -> Int -- ^ Buffer size for the fire hose threads
+                -> (Request -> a ->  Bool) -- ^ A filtering function for fire hose messages. Only messages that match this functions will be passed. The request can be used to build the filter.
+                -> (a -> Builder) -- ^ The serialization function
+                -> IO (Conduit a m a)
+firehoseConduit port buffersize getFilter serialize = do
+    fh <- atomically newFirehose
+    let settings = defaultSettings { settingsPort = port, settingsTimeout = 3600 }
+    void $ forkIO (runSettings settings (firehoseApp buffersize getFilter serialize fh))
+    return (CL.mapM (\m -> liftIO (atomically (writeEvent fh m)) >> return m))
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2013, Simon Marechal
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Simon Marechal nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/stm-firehose.cabal b/stm-firehose.cabal
new file mode 100644
--- /dev/null
+++ b/stm-firehose.cabal
@@ -0,0 +1,40 @@
+-- Initial stm-firehose.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                stm-firehose
+version:             0.1.2
+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
+license-file:        LICENSE
+author:              Simon Marechal
+maintainer:          bartavelle@gmail.com
+-- copyright:           
+category:            Network
+build-type:          Simple
+-- extra-source-files:  
+cabal-version:       >=1.10
+
+source-repository head
+  type: git
+  location: git://github.com/bartavelle/stm-firehose.git
+
+
+library
+  exposed-modules:     Control.Concurrent.STM.Firehose, Data.Conduit.Network.Firehose
+  ghc-options:         -Wall
+  -- other-modules:       
+  -- other-extensions:    
+  build-depends:       base >=4.6 && <4.7, stm >=2.4 && <2.5, stm-chans >=3.0 && <3.1, conduit >=1.0 && <1.1, network-conduit >=1.0 && <1.1, stm-conduit >=2.1 && <2.2, transformers >=0.3 && <0.4,
+                        wai >= 2.0 && < 2.1, http-types == 0.8.*, blaze-builder == 0.3.*, warp >= 2.0 && < 2.1
+  -- hs-source-dirs:      
+  default-language:    Haskell2010
+
+Test-Suite test-stm
+  hs-source-dirs: tests
+  type:           exitcode-stdio-1.0
+  ghc-options:    -Wall -threaded -rtsopts
+  build-depends:  base,stm-firehose,hspec,stm,HUnit
+  main-is:        stmtest.hs
+  default-language:    Haskell2010
+
diff --git a/tests/stmtest.hs b/tests/stmtest.hs
new file mode 100644
--- /dev/null
+++ b/tests/stmtest.hs
@@ -0,0 +1,56 @@
+module Main where
+
+import Test.Hspec
+import Control.Concurrent.STM
+import Control.Concurrent.STM.Firehose
+import Control.Monad
+import Test.HUnit
+import Control.Applicative
+
+intFH :: STM (Firehose Int)
+intFH = newFirehose
+
+main :: IO ()
+main = hspec $ parallel $ do
+    describe "Fire hose with no subscriptions" $ do
+        it "must not block" $ do
+            fh <- atomically intFH
+            mapM_ (atomically . writeEvent fh) [1..10000]
+            atomically (mapM_ (writeEvent fh) [1..10000])
+    describe "Fire hose with a single subscription" $ do
+        it "must give the oldest items in case of overflow" $ do
+            out <- atomically $ do
+                fh <- intFH
+                sub <- subscribe 10 fh
+                mapM_ (writeEvent fh) [1..10000]
+                replicateM 10 (readEvent sub)
+            map Just [1..10] @=? out
+        it "must not block or close when unsubscribed" $ do
+            out <- atomically $ do
+                fh <- intFH
+                sub <- subscribe 10 fh
+                mapM_ (writeEvent fh) [1..100]
+                unsubscribe sub
+                mapM_ (writeEvent fh) [101..200]
+                sub' <- subscribe 10 fh
+                mapM_ (writeEvent fh) [201..300]
+                replicateM 10 (readEvent sub')
+            map Just [201..210] @=? out
+    describe "Fire hose with multiple subscriptions" $ do
+        it "must accept multiple subscriptions" $ do
+            (o1,o2,o3,o4) <- atomically $ do
+                fh <- intFH
+                sub1 <- subscribe 10 fh
+                writeEvent fh 1
+                sub2 <- subscribe 10 fh
+                writeEvent fh 2
+                sub3 <- subscribe 10 fh
+                writeEvent fh 3
+                sub4 <- subscribe 10 fh
+                mapM_ (writeEvent fh) [201..300]
+                (,,,) <$> replicateM 10 (readEvent sub1) <*> replicateM 10 (readEvent sub2) <*> replicateM 10 (readEvent sub3) <*> replicateM 10 (readEvent sub4)
+            map Just (take 10 ([1,2,3] ++ [201..])) @=? o1
+            map Just (take 10 ([2,3] ++ [201..])) @=? o2
+            map Just (take 10 ([3] ++ [201..])) @=? o3
+            map Just (take 10 ([201..])) @=? o4
+
