Giter Club home page Giter Club logo

Comments (5)

erikh avatar erikh commented on May 26, 2024

Sorry, gave you the wrong link: https://github.com/aws/aws-sdk-ruby/blob/master/lib/aws/core/data.rb#L230

Fundamentally this lies, because methods defined on Object will never hit your method missing proxy, and therefore in this case I've duplicated AWS::Core::Data::List, which of course does not duplicate the array that it's delegating to.

from aws-sdk-ruby.

lsegal avatar lsegal commented on May 26, 2024

To clarify: it seems like the underlying issue here is that calling #dup on Data::List will not perform a deep copy-- that and the fact that our docs are misleading in reporting an "Array" return rather than the proper Data::List class that is returned (which actually wraps the Array). I think we can fix both of those things, so that a) the docs don't refer to the returned instance data as a plain array, and, b) we can better handle dup to perform a deep copy so they work better when a user wants to mutate the original object.

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 26, 2024

The AWS::Core::Data classes were added quite a while ago. The client classes (like AWS::EC2::Client) used to construct responses where the values where dynamically created objects with methods punched onto them. This proved to be a performance bottle neck. To address the performance issues, the client response data objects were changed to plain old nested hashes and arrays.

AWS::Core::Data and AWS::Core::Data::List were added to provide a backwards compatible interface for accessing response data.

resp = ec2.client.describe_regions

# deprecated interface, currently handled via AWS::Core::Data
resp.region_info[0].region_name

# preferred access style
resp[:region_info].first[:region_name]

Accessing response data via #[] returns plain old hashes and arrays. Accessing response attributes via named methods return these same structures wrapped. Method style access is deprecated and will not exist in version 2. Unfortunately some sections of the SDK still access response data via the old interfaces. The AWS::EC2::Instance#create method is one such section. Unfortunately this abstraction leaked out because of the call to #map in this method.

I agree with Loren, the core data abstractions can be improved (to prevent this issue). That said, I consider this also a bug. The #create method previously did return an array and the documentation should probably not change. Ideally all such uses of response objects through method missing (that returns a core data object) should be removed.

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 26, 2024

Commit 79cbc73 should resolve the immediate issue of AWS::EC2::InstanceCollection#create not returning an actual array. Changes still need to be made to the core data classes.

from aws-sdk-ruby.

trevorrowe avatar trevorrowe commented on May 26, 2024

I pushed a branch with a proposed change to the core data classes (core-data-fix branch). You can view the changes here: bfc4dc6.

from aws-sdk-ruby.

Related Issues (20)

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.