Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Request Parameters #62

Closed
IbottaBaier opened this issue Apr 11, 2017 · 2 comments
Closed

Update Request Parameters #62

IbottaBaier opened this issue Apr 11, 2017 · 2 comments

Comments

@IbottaBaier
Copy link

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

@awood45
Copy link
Member

awood45 commented Apr 14, 2017

I hear what you're saying. I think since a V2 bump is planned anyways to support the modularized SDK, I may look to include some API adjustments.

@mullermp
Copy link
Contributor

Duplicate of #59

@mullermp mullermp marked this as a duplicate of #59 Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants