|
@@ -2,11 +2,11 @@
|
|
|
|
|
|
module Walrus.Backend (
|
|
module Walrus.Backend (
|
|
Backend(..),
|
|
Backend(..),
|
|
- BackendHandler,
|
|
|
|
|
|
+ LazyHandler,
|
|
module Walrus.Backend.Metadata,
|
|
module Walrus.Backend.Metadata,
|
|
parseBackend,
|
|
parseBackend,
|
|
callBackend,
|
|
callBackend,
|
|
- runBackendOnce
|
|
|
|
|
|
+ runLazyOnce
|
|
) where
|
|
) where
|
|
|
|
|
|
import qualified Data.Attoparsec.ByteString.Char8 as A
|
|
import qualified Data.Attoparsec.ByteString.Char8 as A
|
|
@@ -31,7 +31,7 @@ import qualified System.Process as P
|
|
data Backend = TCPBackend String Int |
|
|
data Backend = TCPBackend String Int |
|
|
ExecBackend String [String] deriving (Show, Read, Ord, Eq)
|
|
ExecBackend String [String] deriving (Show, Read, Ord, Eq)
|
|
|
|
|
|
-type BackendHandler = Metadata -> LBS.ByteString -> IO (Either String (Metadata, LBS.ByteString))
|
|
|
|
|
|
+type LazyHandler = Metadata -> LBS.ByteString -> IO (Either String (Metadata, LBS.ByteString))
|
|
|
|
|
|
parseBackend :: A.Parser Backend
|
|
parseBackend :: A.Parser Backend
|
|
parseBackend = A.choice [
|
|
parseBackend = A.choice [
|
|
@@ -79,8 +79,8 @@ callBackend b (m, qdt) = do
|
|
intBk (ExecBackend f aa) = runExec f aa
|
|
intBk (ExecBackend f aa) = runExec f aa
|
|
repParse = parseMetadata
|
|
repParse = parseMetadata
|
|
|
|
|
|
-runBackendOnce :: UniformIO u => u -> BackendHandler -> IO (Either String ())
|
|
|
|
-runBackendOnce u f = withTarget u $ do
|
|
|
|
|
|
+runLazyOnce :: UniformIO u => u -> LazyHandler -> IO (Either String ())
|
|
|
|
+runLazyOnce u f = withTarget u $ do
|
|
m' <- runAttoparsec parseMetadata
|
|
m' <- runAttoparsec parseMetadata
|
|
case m' of
|
|
case m' of
|
|
Left e -> return . Left . show $ e
|
|
Left e -> return . Left . show $ e
|