William Cheng c5a0374d2b
[Ruby] add useAutoload option to use autoload instead of require (#13153)
* [Ruby] Use Ruby autoload to lower memory usage and load times

Fixes #12648

Requiring all models up front can be very expensive in both time and
memory if there are many models. In an example client with 6000 models,
this would consume nearly 400MB of memory and take about 7 seconds to
load. This is mostly unnecessary as most users of the client library
will only actually use a small percentage of the library.

The changes in this commit use Ruby's autoload capability to defer the
loading until the constant is actually used. In that same example client
with 6000 models, when initially requiring the library, the memory
usage dropped to ~20MB and loaded in 0.3 seconds. As the constants are
loaded on-demand, the memory would increase towards that 400MB ceiling,
but if only a few constants are actually used, then memory will never
actually hit that ceiling.

An additional side effect of using Ruby's autoload is that the order of
declaring the constants is not important, as Ruby will naturally load
them in the correct order when they are needed. Thus, this commit obviates
PR #9103 and fixes #4690.

* add option to use autoload in ruby client

* test ruby clients only

* add tests

* update samples

* Revert "test ruby clients only"

This reverts commit 0aaf71cd4cc5d266f824b261a4d312f07bd589e5.

* update doc

Co-authored-by: Jason Frey <fryguy9@gmail.com>
2022-08-11 12:45:13 +08:00

601 B

Petstore::MapTest

Properties

Name Type Description Notes
map_map_of_string Hash<String, Hash<String, String>> [optional]
map_of_enum_string Hash<String, String> [optional]
direct_map Hash<String, Boolean> [optional]
indirect_map Hash<String, Boolean> [optional]

Example

require 'petstore'

instance = Petstore::MapTest.new(
  map_map_of_string: null,
  map_of_enum_string: null,
  direct_map: null,
  indirect_map: null
)