Giter Site home page Giter Site logo

current's Introduction

DynamoDB client for Erlang

Current is an Erlang client for Amazons DynamoDB service. It exposes the raw JSON API described in the DynamoDB documentation, taking input and giving output in terms compatible with jiffy. Current can also retry requests when appropriate, for example when you're throttled due using all your provisioned throughput or using all available socket connections to DynamoDB.

At the moment, current uses the experimental HTTP client party which tries to do away with the single process bottleneck found in lhttpc. Although it's used in production at Game Analytics without any problems found, it might not be ready for prime time just yet.

Usage

1> application:ensure_all_started(current).
{ok,[party,current]}
2> party:connect(<<"http://dynamodb.us-east-1.amazonaws.com">>, 2).
ok
3> application:set_env(current, endpoint, <<"us-east-1">>).
ok
4> application:set_env(current, access_key, <<"foo">>).
ok
5> application:set_env(current, secret_access_key, <<"bar">>).
ok

6> GetRequest = {[{<<"TableName">>, <<"current_test_table">>}, {<<"Key">>, {[{<<"hash_key">>, {[{<<"N">>, <<"1">>}]}}, {<<"range_key">>, {[{<<"N">>, <<"1">>}]}}]}}]}.
{[{<<"TableName">>,<<"current_test_table">>},
  {<<"Key">>,
   {[{<<"hash_key">>,{[{<<"N">>,<<"1">>}]}},
     {<<"range_key">>,{[{<<"N">>,<<"1">>}]}}]}}]}

7> current:get_item(GetRequest).
{ok,{[{<<"ConsumedCapacity">>,
       {[{<<"CapacityUnits">>,0.5},
         {<<"TableName">>,<<"current_test_table">>}]}},
      {<<"Item">>,
       {[{<<"hash_key">>,{[{<<"N">>,<<"1">>}]}},
         {<<"range_key">>,{[{<<"N">>,<<"1">>}]}}]}}]}}

With the new maps datastructure life will be great.

Instrumentation

Current will call functions in the module specified in the callback_mod environment variable. At the moment, you need to implement two functions: request_complete/3 and request_error/3, see src/current_callback.erl.

request_complete(Operation, StartTimestamp, ConsumedCapacity) ->
    statman_histogram:record_value({ddb, Operation}, StartTimestamp),
    ok.

All calls to DynamoDB will have the ReturnConsumedCapacity value set to TOTAL by default. When DynamoDB returns the ConsumedCapacity, current will forward it to your callback module. Keep in mind that for batch requests it is a list containing capacity for one or more tables.

Testing

If you provide AWS credentials in priv/aws_credentials.term (see priv/aws_credentials_term.template), you can run the test suite. Tables will be created under your account.

current's People

Contributors

chrisavl avatar eproxus avatar knutin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.