packages feed

hworker-ses 0.1.1.0 → 0.1.1.1

raw patch · 2 files changed

+20/−22 lines, 2 filesdep ~amazonkadep ~amazonka-coredep ~amazonka-sesnew-uploader

Dependency ranges changed: amazonka, amazonka-core, amazonka-ses

Files

hworker-ses.cabal view
@@ -1,8 +1,8 @@ name:                hworker-ses-version:             0.1.1.0+version:             0.1.1.1 synopsis:            Library for sending email with Amazon's SES and hworker description:         See README.-homepage:            http://github.com/dbp/hworker-ses+homepage:            http://github.com/position/hworker-ses license:             ISC license-file:        LICENSE author:              Daniel Patterson@@ -21,9 +21,9 @@                      , time                      , aeson                      , text-                     , amazonka >= 1-                     , amazonka-core >= 1-                     , amazonka-ses >= 1+                     , amazonka >= 1.4.4+                     , amazonka-core >= 1.4.4+                     , amazonka-ses >= 1.4.4                      , lens                      , unordered-containers   default-language:    Haskell2010
src/System/Hworker/SES.hs view
@@ -6,7 +6,7 @@ {-# LANGUAGE ScopedTypeVariables   #-} module System.Hworker.SES ( SESWorker                           , SESWorkerWith-                          , SESState+                          , SESState(..)                           , SESJob(..)                           , SESConfig(..)                           , RedisConnection(..)@@ -20,12 +20,11 @@     ) where  import           Control.Applicative     ((<|>))-import           Control.Arrow           ((&&&)) import           Control.Concurrent      (threadDelay) import           Control.Concurrent.MVar (MVar, newMVar, putMVar, takeMVar) import           Control.Exception       (SomeException, catch) import           Control.Lens            (set)-import           Control.Monad           (mzero)+import           Control.Monad           (mzero, void) import           Data.Aeson              (FromJSON (..), ToJSON (..),                                           Value (Object, String), object, (.:),                                           (.=))@@ -35,13 +34,12 @@ import qualified Data.Text               as T import           Data.Time.Clock         (UTCTime, diffUTCTime, getCurrentTime) import           GHC.Generics-import           Network.AWS             (Credentials (Discover),-                                          Region (NorthVirginia), newEnv,+import           Network.AWS             (Credentials (Discover), newEnv,                                           runAWS, runResourceT, send) import           Network.AWS.SES         hiding (Success) import           Network.AWS.Types       (Error) import           System.Hworker          hiding (create, createWith)-import qualified System.Hworker          as Hworker (create, createWith)+import qualified System.Hworker          as Hworker (createWith)  type SESWorkerWith a = Hworker (SESState a) (SESJob a) type SESWorker = SESWorkerWith ()@@ -50,7 +48,7 @@                            , sesSource  :: Text                            , sesRecents :: MVar [UTCTime]                            , sesAfter   :: SESJob a -> IO ()-                           , sesLogger  :: forall a. Show a => a -> IO ()+                           , sesLogger  :: forall b. Show b => b -> IO ()                            }  data SESJob a = SESJob { sesEmTo       :: Text@@ -78,7 +76,7 @@   parseJSON _ = mzero  instance (ToJSON a, FromJSON a, Show a) => Job (SESState a) (SESJob a) where-  job state@(SESState limit source recents after log) j@(SESJob to subj btxt bhtml payload) =+  job state@(SESState limit source recents after log') j@(SESJob to' subj btxt bhtml _payload) =     do now <- getCurrentTime        rs <- takeMVar recents        let active = filter ((< 1) . diffUTCTime now) rs@@ -86,10 +84,10 @@        if count >= limit           then putMVar recents active >> threadDelay 100000 >> job state j           else do putMVar recents (now : active)-                  awsenv <- newEnv NorthVirginia Discover+                  awsenv <- newEnv Discover                   r <- catch (runResourceT $ runAWS awsenv $-                       do send (sendEmail source-                                          (set dToAddresses [to]+                       do void $ send (sendEmail source+                                          (set dToAddresses [to']                                                             destination)                                           (message (content subj)                                                    (set bHTML@@ -99,12 +97,12 @@                                                         body)))                           return Success)                           (\(err::Error) ->-                             do log err+                             do log' err                                 return (Failure (T.pack (show err))))                   case r of                     Success -> catch (after j)                                      (\(e::SomeException) ->-                                       log ("hworker-ses callback raised exception: " <> show e))+                                       log' ("hworker-ses callback raised exception: " <> show e))                     _ -> return ()                   return r @@ -112,8 +110,8 @@      SESConfig { sesconfigName             :: Text                , sesconfigLimit            :: Int                , sesconfigSource           :: Text-               , sesconfigAfter            :: (SESJob a -> IO ())-               , sesconfigLogger           :: (forall a. Show a => a -> IO ())+               , sesconfigAfter            :: SESJob a -> IO ()+               , sesconfigLogger           :: forall b. Show b => b -> IO ()                , sesconfigFailedQueueSize  :: Int                , sesconfigRedisConnectInfo :: RedisConnection                }@@ -146,12 +144,12 @@ createWith :: (ToJSON a, FromJSON a, Show a)            => SESConfig a            -> IO (SESWorkerWith a)-createWith (SESConfig name limit source after logger failed redis) =+createWith (SESConfig name limit source after logger failed' redis) =   do recents <- newMVar []      Hworker.createWith                (defaultHworkerConfig name                                      (SESState limit source recents after logger)) {                                      hwconfigRedisConnectInfo = redis-                                    ,hwconfigFailedQueueSize = failed+                                    ,hwconfigFailedQueueSize = failed'                                     ,hwconfigLogger = logger                }