Record.update! only accepts record attributes as parameters, disallowing the configuration of 'return_value' or 'return_consumed_capacity'.
To reiterate my solution describe in #59:
To handle this I created a SimpleDelegator which delegates an Aws::DynamoDB::Client and provides additional functionality:
class InterceptClient < SimpleDelegator
attr_accessor :update_item_params
# inject additional parameters for update requests
def update_item(request)
super(request.merge(update_item_params))
end
end
I then created a new_client function for generating clients (mainly exposed to be overridden in test, if necessary):
# Spawns a new client with necessary request parameter overrides.
def self.new_client
client = InterceptClient.new(Aws::DynamoDB::Client.new(stub_responses: Rails.env.test?))
client.update_item_params = { return_values: 'ALL_NEW' }
client
end
This is severely limiting due to the fact that the class and all instances share the same client - this means ALL updates must return 'ALL_NEW' attributes; there is no way to (safely) change that value in a multi-threaded environment (using Shoryuken for processing SQS messages and reading/writing Dynamo).
Record.update!
only accepts record attributes as parameters, disallowing the configuration of 'return_value' or 'return_consumed_capacity'.To reiterate my solution describe in #59:
To handle this I created a
SimpleDelegator
which delegates anAws::DynamoDB::Client
and provides additional functionality:I then created a
new_client
function for generating clients (mainly exposed to be overridden in test, if necessary):This is severely limiting due to the fact that the class and all instances share the same client - this means ALL updates must return 'ALL_NEW' attributes; there is no way to (safely) change that value in a multi-threaded environment (using Shoryuken for processing SQS messages and reading/writing Dynamo).