antiope-core (empty) → 1.0.0
raw patch · 8 files changed
+184/−0 lines, 8 filesdep +amazonkadep +amazonka-coredep +antiope-coresetup-changed
Dependencies added: amazonka, amazonka-core, antiope-core, base, bytestring, http-client, lens, resourcet, transformers
Files
- ChangeLog.md +3/−0
- LICENSE +30/−0
- README.md +1/−0
- Setup.hs +2/−0
- antiope-core.cabal +67/−0
- src/Antiope/Core.hs +29/−0
- src/Antiope/Env.hs +50/−0
- test/Spec.hs +2/−0
+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for antiope-core++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Arbor Networks (c) 2018++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of Alexey Raga nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,1 @@+# antiope-core
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ antiope-core.cabal view
@@ -0,0 +1,67 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 53c4a0dfa1e3b0dff9ab29a31e4deb8d999ce4e32446d1ad56bac161798af9f8++name: antiope-core+version: 1.0.0+description: Please see the README on Github at <https://github.com/arbor/antiope#readme>+category: Services+homepage: https://github.com/arbor/antiope#readme+bug-reports: https://github.com/arbor/antiope/issues+author: Tyler Durden+maintainer: mayhem@arbor.net+copyright: Arbor Networks+license: MIT+license-file: LICENSE+build-type: Simple+cabal-version: >= 1.10++extra-source-files:+ ChangeLog.md+ README.md++source-repository head+ type: git+ location: https://github.com/arbor/antiope++library+ hs-source-dirs:+ src+ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -msse4.2+ build-depends:+ amazonka+ , amazonka-core+ , base >=4.7 && <5+ , bytestring+ , http-client+ , lens+ , resourcet+ , transformers+ exposed-modules:+ Antiope.Core+ Antiope.Env+ other-modules:+ Paths_antiope_core+ default-language: Haskell2010++test-suite antiope-core-test+ type: exitcode-stdio-1.0+ main-is: Spec.hs+ hs-source-dirs:+ test+ ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -O2 -msse4.2 -threaded -rtsopts -with-rtsopts=-N+ build-depends:+ amazonka+ , amazonka-core+ , antiope-core+ , base >=4.7 && <5+ , bytestring+ , http-client+ , lens+ , resourcet+ , transformers+ other-modules:+ Paths_antiope_core+ default-language: Haskell2010
+ src/Antiope/Core.hs view
@@ -0,0 +1,29 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}++module Antiope.Core+( module Network.AWS.Data.Text+, AWS.Env+, AWS.HasEnv(..)+, AWS.MonadAWS+, AWS.runAWS+, AWS.send+, AWS.runResourceT+, AWS.liftAWS+, AWS.sinkMD5, AWS.sinkSHA256+, AWS.AWS+, AWS.catching+, AWS.Error(..)+, AWS.ErrorCode(..), AWS.errorCode+, AWS.Region(..)+, AWS.LogLevel(..)+)+where++import Control.Monad.Trans.Class (lift)+import Control.Monad.Trans.Resource (ResourceT)+import Network.AWS.Data.Text (FromText (..), Text, ToText (..), fromText, toText)++import qualified Network.AWS as AWS++instance AWS.MonadAWS m => AWS.MonadAWS (ResourceT m) where+ liftAWS = lift . AWS.liftAWS
+ src/Antiope/Env.hs view
@@ -0,0 +1,50 @@+module Antiope.Env+( mkEnv+, AWS.Env+, AWS.HasEnv(..)+, AWS.LogLevel(..)+, AWS.Region(..)+)+where++import Control.Lens+import Control.Monad.Trans.AWS hiding (LogLevel)+import qualified Data.ByteString as BS+import Data.ByteString.Builder+import qualified Data.ByteString.Char8 as C8+import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString.Lazy.Internal as LBS++import qualified Network.AWS as AWS+import Network.HTTP.Client (HttpException (..), HttpExceptionContent (..))++mkEnv :: Region -> (AWS.LogLevel -> LBS.ByteString -> IO ()) -> IO AWS.Env+mkEnv region lg = do+ lgr <- newAwsLogger lg+ newEnv Discover+ <&> envLogger .~ lgr+ <&> envRegion .~ region+ <&> envRetryCheck .~ retryPolicy 5++newAwsLogger :: Monad m => (AWS.LogLevel -> LBS.ByteString -> IO ()) -> m AWS.Logger+newAwsLogger lg = return $ \y b ->+ case toLazyByteString b of+ msg | BS.isInfixOf (C8.pack "404 Not Found") (L.toStrict msg) -> pure ()+ msg -> lg y msg++retryPolicy :: Int -> Int -> HttpException -> Bool+retryPolicy maxNum attempt ex = (attempt <= maxNum) && shouldRetry ex++shouldRetry :: HttpException -> Bool+shouldRetry ex = case ex of+ HttpExceptionRequest _ ctx -> case ctx of+ ResponseTimeout -> True+ ConnectionTimeout -> True+ ConnectionFailure _ -> True+ InvalidChunkHeaders -> True+ ConnectionClosed -> True+ InternalException _ -> True+ NoResponseDataReceived -> True+ ResponseBodyTooShort _ _ -> True+ _ -> False+ _ -> False
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"