summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibbyHoracek <>2017-09-13 00:32:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-09-13 00:32:00 (GMT)
commita7922f4ad577400c0686e5fcbd0d4798a03a41ab (patch)
treeaeb56388d1b55f1165470e74ed8ab89954109234
parent0a64cf58679d253111c37709fa949f56aa925aa8 (diff)
version 0.1.1.1HEAD0.1.1.1master
-rw-r--r--hworker-ses.cabal10
-rw-r--r--src/System/Hworker/SES.hs32
2 files changed, 20 insertions, 22 deletions
diff --git a/hworker-ses.cabal b/hworker-ses.cabal
index 11e836f..757f6f7 100644
--- a/hworker-ses.cabal
+++ b/hworker-ses.cabal
@@ -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 @@ library
, 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
diff --git a/src/System/Hworker/SES.hs b/src/System/Hworker/SES.hs
index 2d4f641..1a28704 100644
--- a/src/System/Hworker/SES.hs
+++ b/src/System/Hworker/SES.hs
@@ -6,7 +6,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
module System.Hworker.SES ( SESWorker
, SESWorkerWith
- , SESState
+ , SESState(..)
, SESJob(..)
, SESConfig(..)
, RedisConnection(..)
@@ -20,12 +20,11 @@ module System.Hworker.SES ( SESWorker
) 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 Data.Text (Text)
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 @@ data SESState a = SESState { sesLimit :: Int
, 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 @@ instance FromJSON a => FromJSON (SESJob a) where
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 @@ instance (ToJSON a, FromJSON a, Show a) => Job (SESState a) (SESJob a) where
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 @@ instance (ToJSON a, FromJSON a, Show a) => Job (SESState a) (SESJob a) where
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 @@ data SESConfig a =
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 @@ create name limit source after =
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
}