Class: Aws::S3::DirectoryDownloader::ObjectProducer Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/aws-sdk-s3/directory_downloader.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Defined Under Namespace

Classes: DownloadEntry

Constant Summary collapse

DEFAULT_QUEUE_SIZE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

100
DONE_MARKER =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

API:

  • private

:done

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ ObjectProducer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ObjectProducer.

API:

  • private



126
127
128
129
130
131
132
133
134
135
# File 'lib/aws-sdk-s3/directory_downloader.rb', line 126

def initialize(opts = {})
  @directory_downloader = opts[:directory_downloader]
  @destination_dir = opts[:destination]
  @bucket = opts[:bucket]
  @client = opts[:client]
  @s3_prefix = opts[:s3_prefix]
  @filter_callback = opts[:filter_callback]
  @request_callback = opts[:request_callback]
  @object_queue = SizedQueue.new(DEFAULT_QUEUE_SIZE)
end

Instance Method Details

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



141
142
143
144
# File 'lib/aws-sdk-s3/directory_downloader.rb', line 141

def close
  @object_queue.close
  @object_queue.clear
end

#closed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

API:

  • private



137
138
139
# File 'lib/aws-sdk-s3/directory_downloader.rb', line 137

def closed?
  @object_queue.closed?
end

#eachObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/aws-sdk-s3/directory_downloader.rb', line 146

def each
  producer_thread = Thread.new do
    stream_objects
    @object_queue << DONE_MARKER
  rescue ClosedQueueError
    # abort requested
  rescue StandardError => e
    close
    raise e
  end

  while (object = @object_queue.shift) && object != DONE_MARKER
    yield object
  end
ensure
  producer_thread.value
end