aws / aws-sdk-ruby-record

Official repository for the aws-record gem, an abstraction for Amazon DynamoDB.
Apache License 2.0
318 stars 41 forks source link

another approach to requesting consumed capacity to save calls #61

Open ciaranlee opened 7 years ago

ciaranlee commented 7 years ago

I want to be able to see how much write capacity individual saves are consuming. At the moment I think it's not possible. This PR fixes that by passing any options supplied to a save call through to the eventual Dynamo call. Supplying return_consumed_capacity: "TOTAL" means the result returned by the save call will show the consumed write capacity.

Here's what it looks like:

> u.save return_consumed_capacity: "TOTAL"

[Aws::DynamoDB::Client 200 0.024123 0 retries] update_item(table_name:"some_table",key:{"id"=>{s:"4e95893384d7ec000300c62b"}},return_consumed_capacity:"TOTAL")

=> #<struct Aws::DynamoDB::Types::UpdateItemOutput
 attributes=nil,
 consumed_capacity=
  #<struct Aws::DynamoDB::Types::ConsumedCapacity
   table_name="some_table",
   capacity_units=10.0,
   table=nil,
   local_secondary_indexes=nil,
   global_secondary_indexes=nil>,
 item_collection_metrics=nil>

I tries another approach in #60 but I prefer this approach because:

awood45 commented 7 years ago

I think we're on the right track. Going to start with a CR pass and then I'll do some integration tests.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.1%) to 97.768% when pulling a037fca9f3aa5b27c6dbc56263546a8df8c87a74 on ciaranlee:cl/another-approach-to-return_consumed_capacity into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.