aws-sdk-s3 1.193.0 → 1.200.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0e94777097f81374f7ae8c0f3bd8c76a6ab248137104477cef54bfbb5f88ae0
4
- data.tar.gz: 2d7dac3b84fcba84b3bcc125e75d95183eb129ee7b1728ea6ca579f575cc2061
3
+ metadata.gz: 50d0c1be8e15a46bcc05e13aeba9bf9ee61addc0decd0c0480a7809a34f7726c
4
+ data.tar.gz: 5b0634d0d3efee830b742591722f62e34acf6f3c0ccbb50ffbbd8b51faacaa92
5
5
  SHA512:
6
- metadata.gz: 197d9315a2d83377a7870741c01d7e417fc23080bb20e947a5063748e334b07cd268d974129b95e8cc1e3ee7d127596c2e0040e204868cae00f4e8fc9af36f2c
7
- data.tar.gz: eb4a3d2fb4570da19d661649f105bb6697392b45a88779178d786595f127c1a6d3d02bc8a56ab128f50a86afb640d5c22836dcc044d48871ab968fa26dff2c77
6
+ metadata.gz: 6f4e85a59226b4b0cebe9ebdecccfcb7a147339992ed740105faf9f7f4423a02fa0d4cd18515341e9ec24a7626bbcde4f2daafa9796dcb6e3e1171bd15cafe7a
7
+ data.tar.gz: 6d76cb2b2cb4b4d0622ea54b8d7300a3eb3246209c9ee9e770888c71bef67fe55ae468c238f390916c3dcaf2b6a02ee10b786774bb6e7aab7cdeccb2e670e87e
data/CHANGELOG.md CHANGED
@@ -1,6 +1,63 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.200.0 (2025-10-15)
5
+ ------------------
6
+
7
+ * Feature - Add lightweight thread pool executor for multipart `download_file`, `upload_file` and `upload_stream`.
8
+
9
+ * Feature - Add custom executor support for `Aws::S3::TransferManager`.
10
+
11
+ 1.199.1 (2025-09-25)
12
+ ------------------
13
+
14
+ * Issue - Update `TransferManager#download_file` and `Object#download_file` documentation regarding temporary file usage and failure handling for different destination types.
15
+
16
+ 1.199.0 (2025-09-08)
17
+ ------------------
18
+
19
+ * Feature - This release includes backward compatibility work on the "Expires" parameter.
20
+
21
+ 1.198.0 (2025-08-26)
22
+ ------------------
23
+
24
+ * Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
25
+
26
+ * Issue - Fix multipart `download_file` to support `Pathname`, `File` and `Tempfile` objects as download destinations.
27
+
28
+ 1.197.0 (2025-08-19)
29
+ ------------------
30
+
31
+ * Issue - When multipart stream uploader fails to complete multipart upload, it calls abort multipart upload.
32
+
33
+ * Issue - For `Aws::S3::Object` class, the following methods have been deprecated: `download_file`, `upload_file` and `upload_stream`. Use `Aws::S3::TransferManager` instead.
34
+
35
+ * Feature - Add `Aws::S3::TransferManager`, a S3 transfer utility that provides upload/download capabilities with automatic multipart handling, progress tracking, and handling of large files.
36
+
37
+ 1.196.1 (2025-08-05)
38
+ ------------------
39
+
40
+ * Issue - Add range validation to multipart download to ensure all parts are successfully processed.
41
+
42
+ * Issue - When multipart uploader fails to complete multipart upload, it calls abort multipart upload.
43
+
44
+ * Issue - Clean up partially downloaded file on multipart `download_file` failure while preserving existing file.
45
+
46
+ 1.196.0 (2025-08-04)
47
+ ------------------
48
+
49
+ * Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
50
+
51
+ 1.195.0 (2025-07-31)
52
+ ------------------
53
+
54
+ * Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
55
+
56
+ 1.194.0 (2025-07-21)
57
+ ------------------
58
+
59
+ * Feature - Code Generated Changes, see `./build_tools` or `aws-sdk-core`'s CHANGELOG.md for details.
60
+
4
61
  1.193.0 (2025-07-15)
5
62
  ------------------
6
63
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.193.0
1
+ 1.200.0
@@ -137,8 +137,8 @@ module Aws::S3
137
137
  # class name or an instance of a plugin class.
138
138
  #
139
139
  # @option options [required, Aws::CredentialProvider] :credentials
140
- # Your AWS credentials. This can be an instance of any one of the
141
- # following classes:
140
+ # Your AWS credentials used for authentication. This can be any class that includes and implements
141
+ # `Aws::CredentialProvider`, or instance of any one of the following classes:
142
142
  #
143
143
  # * `Aws::Credentials` - Used for configuring static, non-refreshing
144
144
  # credentials.
@@ -166,22 +166,24 @@ module Aws::S3
166
166
  # * `Aws::CognitoIdentityCredentials` - Used for loading credentials
167
167
  # from the Cognito Identity service.
168
168
  #
169
- # When `:credentials` are not configured directly, the following
170
- # locations will be searched for credentials:
169
+ # When `:credentials` are not configured directly, the following locations will be searched for credentials:
171
170
  #
172
171
  # * `Aws.config[:credentials]`
172
+ #
173
173
  # * The `:access_key_id`, `:secret_access_key`, `:session_token`, and
174
174
  # `:account_id` options.
175
- # * ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY'],
176
- # ENV['AWS_SESSION_TOKEN'], and ENV['AWS_ACCOUNT_ID']
175
+ #
176
+ # * `ENV['AWS_ACCESS_KEY_ID']`, `ENV['AWS_SECRET_ACCESS_KEY']`,
177
+ # `ENV['AWS_SESSION_TOKEN']`, and `ENV['AWS_ACCOUNT_ID']`.
178
+ #
177
179
  # * `~/.aws/credentials`
180
+ #
178
181
  # * `~/.aws/config`
179
- # * EC2/ECS IMDS instance profile - When used by default, the timeouts
180
- # are very aggressive. Construct and pass an instance of
181
- # `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
182
- # enable retries and extended timeouts. Instance profile credential
183
- # fetching can be disabled by setting ENV['AWS_EC2_METADATA_DISABLED']
184
- # to true.
182
+ #
183
+ # * EC2/ECS IMDS instance profile - When used by default, the timeouts are very aggressive.
184
+ # Construct and pass an instance of `Aws::InstanceProfileCredentials` or `Aws::ECSCredentials` to
185
+ # enable retries and extended timeouts. Instance profile credential fetching can be disabled by
186
+ # setting `ENV['AWS_EC2_METADATA_DISABLED']` to `true`.
185
187
  #
186
188
  # @option options [required, String] :region
187
189
  # The AWS region to connect to. The configured `:region` is
@@ -219,6 +221,11 @@ module Aws::S3
219
221
  # When false, the request will raise a `RetryCapacityNotAvailableError` and will
220
222
  # not retry instead of sleeping.
221
223
  #
224
+ # @option options [Array<String>] :auth_scheme_preference
225
+ # A list of preferred authentication schemes to use when making a request. Supported values are:
226
+ # `sigv4`, `sigv4a`, `httpBearerAuth`, and `noAuth`. When set using `ENV['AWS_AUTH_SCHEME_PREFERENCE']` or in
227
+ # shared config as `auth_scheme_preference`, the value should be a comma-separated list.
228
+ #
222
229
  # @option options [Boolean] :client_side_monitoring (false)
223
230
  # When `true`, client-side metrics will be collected for all API requests from
224
231
  # this client.
@@ -333,8 +340,8 @@ module Aws::S3
333
340
  # When an EventStream or Proc object is provided, it will be used as callback for each chunk of event stream response received along the way.
334
341
  #
335
342
  # @option options [String] :profile ("default")
336
- # Used when loading credentials from the shared credentials file
337
- # at HOME/.aws/credentials. When not specified, 'default' is used.
343
+ # Used when loading credentials from the shared credentials file at `HOME/.aws/credentials`.
344
+ # When not specified, 'default' is used.
338
345
  #
339
346
  # @option options [String] :request_checksum_calculation ("when_supported")
340
347
  # Determines when a checksum will be calculated for request payloads. Values are:
@@ -466,8 +473,8 @@ module Aws::S3
466
473
  # `Aws::Telemetry::OTelProvider` for telemetry provider.
467
474
  #
468
475
  # @option options [Aws::TokenProvider] :token_provider
469
- # A Bearer Token Provider. This can be an instance of any one of the
470
- # following classes:
476
+ # Your Bearer token used for authentication. This can be any class that includes and implements
477
+ # `Aws::TokenProvider`, or instance of any one of the following classes:
471
478
  #
472
479
  # * `Aws::StaticTokenProvider` - Used for configuring static, non-refreshing
473
480
  # tokens.
@@ -21728,7 +21735,7 @@ module Aws::S3
21728
21735
  tracer: tracer
21729
21736
  )
21730
21737
  context[:gem_name] = 'aws-sdk-s3'
21731
- context[:gem_version] = '1.193.0'
21738
+ context[:gem_version] = '1.200.0'
21732
21739
  Seahorse::Client::Request.new(handlers, context)
21733
21740
  end
21734
21741
 
@@ -358,8 +358,8 @@ module Aws
358
358
  # {Client#complete_multipart_upload},
359
359
  # and {Client#upload_part} can be provided.
360
360
  #
361
- # @option options [Integer] :thread_count (10) The number of parallel
362
- # multipart uploads
361
+ # @option options [Integer] :thread_count (10) The number of parallel multipart uploads.
362
+ # An additional thread is used internally for task coordination.
363
363
  #
364
364
  # @option options [Boolean] :tempfile (false) Normally read data is stored
365
365
  # in memory when building the parts in order to complete the underlying
@@ -383,29 +383,28 @@ module Aws
383
383
  # @see Client#complete_multipart_upload
384
384
  # @see Client#upload_part
385
385
  def upload_stream(options = {}, &block)
386
- uploading_options = options.dup
386
+ upload_opts = options.merge(bucket: bucket_name, key: key)
387
+ executor = DefaultExecutor.new(max_threads: upload_opts.delete(:thread_count))
387
388
  uploader = MultipartStreamUploader.new(
388
389
  client: client,
389
- thread_count: uploading_options.delete(:thread_count),
390
- tempfile: uploading_options.delete(:tempfile),
391
- part_size: uploading_options.delete(:part_size)
390
+ executor: executor,
391
+ tempfile: upload_opts.delete(:tempfile),
392
+ part_size: upload_opts.delete(:part_size)
392
393
  )
393
394
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
394
- uploader.upload(
395
- uploading_options.merge(bucket: bucket_name, key: key),
396
- &block
397
- )
395
+ uploader.upload(upload_opts, &block)
398
396
  end
397
+ executor.shutdown
399
398
  true
400
399
  end
400
+ deprecated(:upload_stream, use: 'Aws::S3::TransferManager#upload_stream', version: 'next major version')
401
401
 
402
402
  # Uploads a file from disk to the current object in S3.
403
403
  #
404
404
  # # small files are uploaded in a single API call
405
405
  # obj.upload_file('/path/to/file')
406
406
  #
407
- # Files larger than or equal to `:multipart_threshold` are uploaded
408
- # using the Amazon S3 multipart upload APIs.
407
+ # Files larger than or equal to `:multipart_threshold` are uploaded using the Amazon S3 multipart upload APIs.
409
408
  #
410
409
  # # large files are automatically split into parts
411
410
  # # and the parts are uploaded in parallel
@@ -421,74 +420,65 @@ module Aws
421
420
  # You can provide a callback to monitor progress of the upload:
422
421
  #
423
422
  # # bytes and totals are each an array with 1 entry per part
424
- # progress = Proc.new do |bytes, totals|
425
- # puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%" }
423
+ # progress = proc do |bytes, totals|
424
+ # puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{totals[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / totals.sum }%"
426
425
  # end
427
426
  # obj.upload_file('/path/to/file', progress_callback: progress)
428
427
  #
429
- # @param [String, Pathname, File, Tempfile] source A file on the local
430
- # file system that will be uploaded as this object. This can either be
431
- # a String or Pathname to the file, an open File object, or an open
432
- # Tempfile object. If you pass an open File or Tempfile object, then
433
- # you are responsible for closing it after the upload completes. When
434
- # using an open Tempfile, rewind it before uploading or else the object
428
+ # @param [String, Pathname, File, Tempfile] source A file on the local file system that will be uploaded as
429
+ # this object. This can either be a String or Pathname to the file, an open File object, or an open
430
+ # Tempfile object. If you pass an open File or Tempfile object, then you are responsible for closing it
431
+ # after the upload completes. When using an open Tempfile, rewind it before uploading or else the object
435
432
  # will be empty.
436
433
  #
437
434
  # @param [Hash] options
438
- # Additional options for {Client#put_object}
439
- # when file sizes below the multipart threshold. For files larger than
440
- # the multipart threshold, options for {Client#create_multipart_upload},
441
- # {Client#complete_multipart_upload},
442
- # and {Client#upload_part} can be provided.
435
+ # Additional options for {Client#put_object} when file sizes below the multipart threshold.
436
+ # For files larger than the multipart threshold, options for {Client#create_multipart_upload},
437
+ # {Client#complete_multipart_upload}, and {Client#upload_part} can be provided.
443
438
  #
444
- # @option options [Integer] :multipart_threshold (104857600) Files larger
445
- # than or equal to `:multipart_threshold` are uploaded using the S3
446
- # multipart APIs.
447
- # Default threshold is 100MB.
439
+ # @option options [Integer] :multipart_threshold (104857600) Files larger han or equal to
440
+ # `:multipart_threshold` are uploaded using the S3 multipart APIs. Default threshold is 100MB.
448
441
  #
449
- # @option options [Integer] :thread_count (10) The number of parallel
450
- # multipart uploads. This option is not used if the file is smaller than
451
- # `:multipart_threshold`.
442
+ # @option options [Integer] :thread_count (10) The number of parallel multipart uploads.
443
+ # This option is not used if the file is smaller than `:multipart_threshold`.
452
444
  #
453
445
  # @option options [Proc] :progress_callback
454
446
  # A Proc that will be called when each chunk of the upload is sent.
455
447
  # It will be invoked with [bytes_read], [total_sizes]
456
448
  #
457
- # @raise [MultipartUploadError] If an object is being uploaded in
458
- # parts, and the upload can not be completed, then the upload is
459
- # aborted and this error is raised. The raised error has a `#errors`
460
- # method that returns the failures that caused the upload to be
461
- # aborted.
449
+ # @raise [MultipartUploadError] If an object is being uploaded in parts, and the upload can not be completed,
450
+ # then the upload is aborted and this error is raised. The raised error has a `#errors` method that
451
+ # returns the failures that caused the upload to be aborted.
462
452
  #
463
- # @return [Boolean] Returns `true` when the object is uploaded
464
- # without any errors.
453
+ # @return [Boolean] Returns `true` when the object is uploaded without any errors.
465
454
  #
466
455
  # @see Client#put_object
467
456
  # @see Client#create_multipart_upload
468
457
  # @see Client#complete_multipart_upload
469
458
  # @see Client#upload_part
470
459
  def upload_file(source, options = {})
471
- uploading_options = options.dup
460
+ upload_opts = options.merge(bucket: bucket_name, key: key)
461
+ executor = DefaultExecutor.new(max_threads: upload_opts.delete(:thread_count))
472
462
  uploader = FileUploader.new(
473
- multipart_threshold: uploading_options.delete(:multipart_threshold),
474
- client: client
463
+ client: client,
464
+ executor: executor,
465
+ multipart_threshold: upload_opts.delete(:multipart_threshold)
475
466
  )
476
467
  response = Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
477
- uploader.upload(
478
- source,
479
- uploading_options.merge(bucket: bucket_name, key: key)
480
- )
468
+ uploader.upload(source, upload_opts)
481
469
  end
482
470
  yield response if block_given?
471
+ executor.shutdown
483
472
  true
484
473
  end
474
+ deprecated(:upload_file, use: 'Aws::S3::TransferManager#upload_file', version: 'next major version')
485
475
 
486
476
  # Downloads a file in S3 to a path on disk.
487
477
  #
488
478
  # # small files (< 5MB) are downloaded in a single API call
489
479
  # obj.download_file('/path/to/file')
490
480
  #
491
- # Files larger than 5MB are downloaded using multipart method
481
+ # Files larger than 5MB are downloaded using multipart method:
492
482
  #
493
483
  # # large files are split into parts
494
484
  # # and the parts are downloaded in parallel
@@ -498,67 +488,68 @@ module Aws
498
488
  #
499
489
  # # bytes and part_sizes are each an array with 1 entry per part
500
490
  # # part_sizes may not be known until the first bytes are retrieved
501
- # progress = Proc.new do |bytes, part_sizes, file_size|
502
- # puts bytes.map.with_index { |b, i| "Part #{i+1}: #{b} / #{part_sizes[i]}"}.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%" }
491
+ # progress = proc do |bytes, part_sizes, file_size|
492
+ # puts bytes.map.with_index { |b, i| "Part #{i + 1}: #{b} / #{part_sizes[i]}" }.join(' ') + "Total: #{100.0 * bytes.sum / file_size}%"
503
493
  # end
504
494
  # obj.download_file('/path/to/file', progress_callback: progress)
505
495
  #
506
- # @param [String] destination Where to download the file to.
496
+ # @param [String, Pathname, File, Tempfile] destination
497
+ # Where to download the file to. This can either be a String or Pathname to the file, an open File object,
498
+ # or an open Tempfile object. If you pass an open File or Tempfile object, then you are responsible for
499
+ # closing it after the download completes. Download behavior varies by destination type:
500
+ #
501
+ # * **String/Pathname paths**: Downloads to a temporary file first, then atomically moves to the final
502
+ # destination. This prevents corruption of any existing file if the download fails.
503
+ # * **File/Tempfile objects**: Downloads directly to the file object without using temporary files.
504
+ # You are responsible for managing the file object's state and closing it after the download completes.
505
+ # If the download fails, the file object may contain partial data.
507
506
  #
508
507
  # @param [Hash] options
509
- # Additional options for {Client#get_object} and #{Client#head_object}
510
- # may be provided.
508
+ # Additional options for {Client#get_object} and #{Client#head_object} may be provided.
511
509
  #
512
- # @option options [String] mode `auto`, `single_request`, `get_range`
513
- # `single_request` mode forces only 1 GET request is made in download,
514
- # `get_range` mode allows `chunk_size` parameter to configured in
515
- # customizing each range size in multipart_download,
516
- # By default, `auto` mode is enabled, which performs multipart_download
510
+ # @option options [String] :mode ("auto") `"auto"`, `"single_request"` or `"get_range"`
517
511
  #
518
- # @option options [Integer] chunk_size required in get_range mode.
512
+ # * `auto` mode is enabled by default, which performs `multipart_download`
513
+ # * `"single_request`" mode forces only 1 GET request is made in download
514
+ # * `"get_range"` mode requires `:chunk_size` parameter to configured in customizing each range size
519
515
  #
520
- # @option options [Integer] thread_count (10) Customize threads used in
521
- # the multipart download.
516
+ # @option options [Integer] :chunk_size required in `"get_range"` mode.
522
517
  #
523
- # @option options [String] version_id The object version id used to
524
- # retrieve the object. For more about object versioning, see:
525
- # https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectVersioning.html
518
+ # @option options [Integer] :thread_count (10) Customize threads used in the multipart download.
526
519
  #
527
- # @option options [String] checksum_mode (ENABLED) When `ENABLED` and
528
- # the object has a stored checksum, it will be used to validate the
529
- # download and will raise an `Aws::Errors::ChecksumError` if
530
- # checksum validation fails. You may provide a `on_checksum_validated`
531
- # callback if you need to verify that validation occurred and which
532
- # algorithm was used. To disable checksum validation, set
533
- # `checksum_mode` to "DISABLED".
520
+ # @option options [String] :checksum_mode ("ENABLED")
521
+ # When `"ENABLED"` and the object has a stored checksum, it will be used to validate the download and will
522
+ # raise an `Aws::Errors::ChecksumError` if checksum validation fails. You may provide a `on_checksum_validated`
523
+ # callback if you need to verify that validation occurred and which algorithm was used.
524
+ # To disable checksum validation, set `checksum_mode` to `"DISABLED"`.
534
525
  #
535
- # @option options [Callable] on_checksum_validated Called each time a
536
- # request's checksum is validated with the checksum algorithm and the
537
- # response. For multipart downloads, this will be called for each
538
- # part that is downloaded and validated.
526
+ # @option options [Callable] :on_checksum_validated
527
+ # Called each time a request's checksum is validated with the checksum algorithm and the
528
+ # response. For multipart downloads, this will be called for each part that is downloaded and validated.
539
529
  #
540
530
  # @option options [Proc] :progress_callback
541
- # A Proc that will be called when each chunk of the download is received.
542
- # It will be invoked with [bytes_read], [part_sizes], file_size.
543
- # When the object is downloaded as parts (rather than by ranges), the
544
- # part_sizes will not be known ahead of time and will be nil in the
545
- # callback until the first bytes in the part are received.
531
+ # A Proc that will be called when each chunk of the download is received. It will be invoked with
532
+ # `bytes_read`, `part_sizes`, `file_size`. When the object is downloaded as parts (rather than by ranges),
533
+ # the `part_sizes` will not be known ahead of time and will be `nil` in the callback until the first bytes
534
+ # in the part are received.
535
+ #
536
+ # @raise [MultipartDownloadError] Raised when an object validation fails outside of service errors.
546
537
  #
547
- # @return [Boolean] Returns `true` when the file is downloaded without
548
- # any errors.
538
+ # @return [Boolean] Returns `true` when the file is downloaded without any errors.
549
539
  #
550
540
  # @see Client#get_object
551
541
  # @see Client#head_object
552
542
  def download_file(destination, options = {})
553
- downloader = FileDownloader.new(client: client)
543
+ download_opts = options.merge(bucket: bucket_name, key: key)
544
+ executor = DefaultExecutor.new(max_threads: download_opts.delete([:thread_count]))
545
+ downloader = FileDownloader.new(client: client, executor: executor)
554
546
  Aws::Plugins::UserAgent.metric('RESOURCE_MODEL') do
555
- downloader.download(
556
- destination,
557
- options.merge(bucket: bucket_name, key: key)
558
- )
547
+ downloader.download(destination, download_opts)
559
548
  end
549
+ executor.shutdown
560
550
  true
561
551
  end
552
+ deprecated(:download_file, use: 'Aws::S3::TransferManager#download_file', version: 'next major version')
562
553
 
563
554
  class Collection < Aws::Resources::Collection
564
555
  alias_method :delete, :batch_delete!
@@ -7,9 +7,11 @@ module Aws
7
7
  autoload :Encryption, 'aws-sdk-s3/encryption'
8
8
  autoload :EncryptionV2, 'aws-sdk-s3/encryption_v2'
9
9
  autoload :FilePart, 'aws-sdk-s3/file_part'
10
+ autoload :DefaultExecutor, 'aws-sdk-s3/default_executor'
10
11
  autoload :FileUploader, 'aws-sdk-s3/file_uploader'
11
12
  autoload :FileDownloader, 'aws-sdk-s3/file_downloader'
12
13
  autoload :LegacySigner, 'aws-sdk-s3/legacy_signer'
14
+ autoload :MultipartDownloadError, 'aws-sdk-s3/multipart_download_error'
13
15
  autoload :MultipartFileUploader, 'aws-sdk-s3/multipart_file_uploader'
14
16
  autoload :MultipartStreamUploader, 'aws-sdk-s3/multipart_stream_uploader'
15
17
  autoload :MultipartUploadError, 'aws-sdk-s3/multipart_upload_error'
@@ -17,13 +19,13 @@ module Aws
17
19
  autoload :ObjectMultipartCopier, 'aws-sdk-s3/object_multipart_copier'
18
20
  autoload :PresignedPost, 'aws-sdk-s3/presigned_post'
19
21
  autoload :Presigner, 'aws-sdk-s3/presigner'
22
+ autoload :TransferManager, 'aws-sdk-s3/transfer_manager'
20
23
 
21
24
  # s3 express session auth
22
25
  autoload :ExpressCredentials, 'aws-sdk-s3/express_credentials'
23
26
  autoload :ExpressCredentialsProvider, 'aws-sdk-s3/express_credentials_provider'
24
27
 
25
28
  # s3 access grants auth
26
-
27
29
  autoload :AccessGrantsCredentials, 'aws-sdk-s3/access_grants_credentials'
28
30
  autoload :AccessGrantsCredentialsProvider, 'aws-sdk-s3/access_grants_credentials_provider'
29
31
  end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aws
4
+ module S3
5
+ # @api private
6
+ class DefaultExecutor
7
+ DEFAULT_MAX_THREADS = 10
8
+ RUNNING = :running
9
+ SHUTTING_DOWN = :shutting_down
10
+ SHUTDOWN = :shutdown
11
+
12
+ def initialize(options = {})
13
+ @max_threads = options[:max_threads] || DEFAULT_MAX_THREADS
14
+ @state = RUNNING
15
+ @queue = Queue.new
16
+ @pool = []
17
+ @mutex = Mutex.new
18
+ end
19
+
20
+ # Submits a task for execution.
21
+ # @param [Object] args Variable number of arguments to pass to the block
22
+ # @param [Proc] block The block to be executed
23
+ # @return [Boolean] Returns true if the task was submitted successfully
24
+ def post(*args, &block)
25
+ @mutex.synchronize do
26
+ raise 'Executor has been shutdown and is no longer accepting tasks' unless @state == RUNNING
27
+
28
+ @queue << [args, block]
29
+ ensure_worker_available
30
+ end
31
+ true
32
+ end
33
+
34
+ # Immediately terminates all worker threads and clears pending tasks.
35
+ # This is a forceful shutdown that doesn't wait for running tasks to complete.
36
+ #
37
+ # @return [Boolean] true when termination is complete
38
+ def kill
39
+ @mutex.synchronize do
40
+ @state = SHUTDOWN
41
+ @pool.each(&:kill)
42
+ @pool.clear
43
+ @queue.clear
44
+ end
45
+ true
46
+ end
47
+
48
+ # Gracefully shuts down the executor, optionally with a timeout.
49
+ # Stops accepting new tasks and waits for running tasks to complete.
50
+ #
51
+ # @param timeout [Numeric, nil] Maximum time in seconds to wait for shutdown.
52
+ # If nil, waits indefinitely. If timeout expires, remaining threads are killed.
53
+ # @return [Boolean] true when shutdown is complete
54
+ def shutdown(timeout = nil)
55
+ @mutex.synchronize do
56
+ return true if @state == SHUTDOWN
57
+
58
+ @state = SHUTTING_DOWN
59
+ @pool.size.times { @queue << :shutdown }
60
+ end
61
+
62
+ if timeout
63
+ deadline = Time.now + timeout
64
+ @pool.each do |thread|
65
+ remaining = deadline - Time.now
66
+ break if remaining <= 0
67
+
68
+ thread.join([remaining, 0].max)
69
+ end
70
+ @pool.select(&:alive?).each(&:kill)
71
+ else
72
+ @pool.each(&:join)
73
+ end
74
+
75
+ @mutex.synchronize do
76
+ @pool.clear
77
+ @state = SHUTDOWN
78
+ end
79
+ true
80
+ end
81
+
82
+ private
83
+
84
+ def ensure_worker_available
85
+ return unless @state == RUNNING
86
+
87
+ @pool.select!(&:alive?)
88
+ @pool << spawn_worker if @pool.size < @max_threads
89
+ end
90
+
91
+ def spawn_worker
92
+ Thread.new do
93
+ while (job = @queue.shift)
94
+ break if job == :shutdown
95
+
96
+ args, block = job
97
+ block.call(*args)
98
+ end
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end