Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Pull across mismi-dynamodb package. #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Version 0.0.4
- Include `mismi-dynamodb`

## Version 0.0.3 (2018-12-27)

- Add support for GHC 8.6.3
Expand Down
1 change: 1 addition & 0 deletions mismi-dynamodb/CHANGELOG.md
1 change: 1 addition & 0 deletions mismi-dynamodb/LICENSE
51 changes: 51 additions & 0 deletions mismi-dynamodb/mismi-dynamodb.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 0.0.4

name:
mismi-dynamodb
author:
Nick Hibberd
maintainer:
Nick Hibberd <[email protected]>
homepage:
https://github.com/nhibberd/mismi
bug-reports:
https://github.com/nhibberd/mismi/issues
synopsis:
AWS Library
description:
mismi-dynamodb is a library that provides a set of common and useful
operations on top of AWS DynamoDB.
category:
AWS
license:
BSD3
license-file:
LICENSE
cabal-version:
>= 1.8
build-type:
Simple
tested-with:
GHC == 8.2.2
, GHC == 8.4.3
, GHC == 8.6.3
extra-source-files:
CHANGELOG.md

library
build-depends:
base >= 3 && < 6
, mismi-p
, mismi-core
, amazonka-dynamodb >= 1.4.0 && < 1.7
, lens >= 4.8 && < 4.18

ghc-options:
-Wall

hs-source-dirs:
src

exposed-modules:
Mismi.DynamoDB.Amazonka
Mismi.DynamoDB.Control
8 changes: 8 additions & 0 deletions mismi-dynamodb/src/Mismi/DynamoDB/Amazonka.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Mismi.DynamoDB.Amazonka (
module AWS
) where


import Network.AWS.DynamoDB as AWS
38 changes: 38 additions & 0 deletions mismi-dynamodb/src/Mismi/DynamoDB/Control.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Mismi.DynamoDB.Control (
configureRetries
) where

import Control.Lens (over, set, (^.), has)

import Mismi (Env)
import Mismi.Amazonka (serviceRetry, retryAttempts, exponentBase, configure, retryCheck, hasCode, hasStatus)

import Network.AWS.DynamoDB (dynamoDB)

import P

-- https://github.com/brendanhay/amazonka/issues/351
configureRetries :: Env -> Env
configureRetries env =
let
check e =
let
check' = dynamoDB ^. serviceRetry . retryCheck
in
case check' e of
Nothing ->
case has (hasCode "ProvisionedThroughputExceeded" . hasStatus 400) e of
True ->
Just "throughput_exceeded_x"
False ->
Nothing
Just x ->
Just x
in
flip configure env .
flip (over serviceRetry) dynamoDB $
set retryAttempts 7 .
set exponentBase 0.6 .
set retryCheck check