Monadic API for tablestorage. #6

Merged
merged 9 commits into from Dec 22, 2012

Projects

None yet

2 participants

@AaronFriel
Contributor

No description provided.

Contributor

The library now completely supports using a shared http-conduit manager and specifying a proxy, performance is way up with this and the monad stack has had a "ResourceT" transformer added to it to support http-conduit. Here is an example program that runs, I would estimate, two orders of magnitude more quickly when using a shared manager:

{-# LANGUAGE OverloadedStrings #-}

import Network.TableStorage
import Control.Monad.Error
import Network.HTTP.Conduit
import Network.Socket.Internal (withSocketsDo)

main :: IO ()
main = withSocketsDo $  do
  let range = [1000..6000] :: [Int]
  let ipsum = EdmString $ Just "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
  manager <- newManager def
  let conf = developmentConf { httpProxy = Just $ Proxy "127.0.0.1" 8888, httpManager = Just $ manager }
  _ <- withTableStorage conf $ createTableIfNecessary "foobar"
  _ <- sequence $ map (\i -> do
    let key = EntityKey i i
    x <- withTableStorage conf $
          insertEntity "baz" (Entity key  [("ipsum",ipsum)])
            `catchError` (\_ -> updateEntity "baz" $ Entity key [("ipsum",ipsum)])
    print x
    ) (map show range)
  closeManager manager
@paf31 paf31 merged commit ad46ce7 into paf31:master Dec 22, 2012
Owner
paf31 commented Dec 22, 2012

Maybe we could check in these small tests as well.

Owner
paf31 commented Dec 22, 2012

v0.2.1 uploaded to Hackage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment