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

add return_consumed_capacity to _perform_save #60

Closed ciaranlee closed 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 allows for a return_consumed_capacity option to be passed in to save calls, and it passes that option through to the dynamodb_client.update_item update call, like this:

> 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>

LMK if the approach looks good?

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 1b0fd1b3cc81c46cf55823746b0f1f909bcc815c on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 1b0fd1b3cc81c46cf55823746b0f1f909bcc815c on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 1b0fd1b3cc81c46cf55823746b0f1f909bcc815c on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 0f92b2ad41bc2e2e1689b39fea9fcad75604c3e4 on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 0f92b2ad41bc2e2e1689b39fea9fcad75604c3e4 on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

coveralls commented 7 years ago

Coverage Status

Coverage decreased (-0.1%) to 97.553% when pulling 0f92b2ad41bc2e2e1689b39fea9fcad75604c3e4 on ciaranlee:cl/add-return_consumed_capacity-option-to-perform_save into cb5f10ff23aaed7d3b47706070f1bb7aa37fb0d8 on aws:master.

ciaranlee commented 7 years ago

Another approach would be to simply take the options passed in to save and pass them through to the dynamodb call. Thinking about it now, I feel like that makes more sense, as there are likely to be other options that folks will want to add, and we can enable that in one go now.

What do you think?

ciaranlee commented 7 years ago

closing in favour of #61