Skip to content

Instantly share code, notes, and snippets.

@lorenzo
Created August 28, 2018 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzo/a2bfa0be4ea78f82034732537b212df0 to your computer and use it in GitHub Desktop.
Save lorenzo/a2bfa0be4ea78f82034732537b212df0 to your computer and use it in GitHub Desktop.
sitesQuery :: Query
sitesQuery = "select id, name from sites"
queryUsersAndCreateCheckpoints :: IO ()
queryUsersAndCreateCheckpoints = do
conn <- mysqlConnect -- my own helper function
statement <- prepareStmt conn sitesQuery
results <-
queryStmtResults conn statement [] >>= -- Query all the sites so they can be processed concurrently
Streams.toList -- The list is small, so we need no streaming
closeStmt conn statement
close conn
files <- mapConcurrently processSingleSite results
...
processSingleSite :: (Int, Text) -> IO (Maybe Text)
processSingleSite siteId, siteName) = do
putStrLn ("Processing site: " ++ siteName)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment