Module erlcloud_ddb_impl

.

Authors: Ransom Richardson (ransom@ransomr.net).

Description

Implementation of requests to DynamoDB. This code is shared accross all API versions.

The pluggable retry function provides a way to customize the retry behavior, as well as log and customize errors that are generated by erlcloud_ddb. In order to not break clients that rely on the error behavior the default error reason can not be changed. But it does not include key information, such as the request_id that you will need if you need to contact AWS support about DynamoDB failures.

Here is an example retry function that provides logging and an updated error reason:

  retry(Error) ->
      RequestId = erlcloud_ddb_impl:request_id_from_error(Error),
      {_, Operation} = lists:keyfind("x-amz-target", 1, Error#ddb2_error.request_headers),
      lager:notice("DDB Attempt: ~p Reason: ~p RequestId: ~p, Request: ~p ~p",
                   [Error#ddb2_error.attempt,
                    Error#ddb2_error.reason,
                    RequestId,
                    Operation,
                    Error#ddb2_error.request_body]),
      Error2 = erlcloud_ddb_impl:error_reason2(Error),
      erlcloud_ddb_impl:retry(Error2).

Data Types

attempt()

attempt() = {attempt, pos_integer()} | {error, term()}

json_return()

json_return() = ok | {ok, jsx:json_term()} | {error, term()}

operation()

operation() = string()

retry_fun()

retry_fun() = retry_fun_v1() | retry_fun_v2()

retry_fun_v1()

retry_fun_v1() = fun((pos_integer(), term()) -> attempt())

retry_fun_v2()

retry_fun_v2() = fun((#ddb2_error{}) -> attempt())

Function Index

backoff/1
error_reason2/1
request/3
request_id_from_error/1
retry/1
retry/2

Function Details

backoff/1

backoff(Attempt::pos_integer()) -> ok

error_reason2/1

error_reason2(Ddb2_error::#ddb2_error{}) -> #ddb2_error{}

request/3

request(Config0::aws_config(), Operation::operation(), Json::jsx:json_term()) -> json_return()

request_id_from_error/1

request_id_from_error(Ddb2_error::#ddb2_error{}) -> string()

retry/1

retry(Ddb2_error::#ddb2_error{}) -> attempt()

retry/2

retry(Attempt::pos_integer(), Reason::term()) -> attempt()


Generated by EDoc