Skip to content

Commit

Permalink
Simpler flushing of responses using blaze.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Turner committed Aug 28, 2012
1 parent 6cb9fc7 commit f232697
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions scalable-server.cabal
Expand Up @@ -3,7 +3,7 @@ Name: scalable-server
Synopsis: Library for writing fast/scalable TCP-based services
Description: Library for writing fast/scalable TCP-based services

Version: 0.3.0
Version: 0.3.1

License: BSD3

Expand Down Expand Up @@ -36,7 +36,6 @@ Library
conduit>=0.5&&<0.6,
network-conduit>=0.5&&<0.6,
attoparsec-conduit>=0.5&&<0.6,
blaze-builder-conduit>=0.5&&<0.6

Extensions: ScopedTypeVariables
ghc-options: -O2
6 changes: 2 additions & 4 deletions src/Network/Server/ScalableServer.hs
Expand Up @@ -6,13 +6,12 @@ module Network.Server.ScalableServer (
RequestPipeline(..), RequestCreator,
RequestProcessor) where

import Blaze.ByteString.Builder (Builder)
import Blaze.ByteString.Builder (Builder, toByteString)
import Data.ByteString
import Data.Conduit
import Data.Conduit.List as CL
import Data.Conduit.Network
import Data.Conduit.Attoparsec
import Data.Conduit.Blaze
import Network.BSD
import qualified Data.Attoparsec as Atto

Expand Down Expand Up @@ -57,6 +56,5 @@ runServer pipe port = do
processRequest :: RequestPipeline a -> Source IO ByteString -> Sink ByteString IO () -> IO ()
processRequest (RequestPipeline parser handler) source sink = do
source $$ (conduitParser parser) =$= CL.map snd =$=
CL.mapM handler =$=
builderToByteStringWith (allNewBuffersStrategy 0) =$
CL.mapM handler =$= CL.map toByteString =$=
sink

0 comments on commit f232697

Please sign in to comment.