remote_files 3.6.0 → 3.7.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59ec945098b2e44d854eefecff7a29217c09c7ea3fd81da6617f8e13ec940589
4
- data.tar.gz: e3ff2aeb923049f688e34a851d951ecacfad9f057d3c3711d3b49cfa040593d5
3
+ metadata.gz: 00b8fe0548d27ed5c3e7f604be263e0c70f0b3fce867c6528886d45372122aa6
4
+ data.tar.gz: a3064a9ef511550b94a4965e55eb2f2b15b45dc2244965a1fedb8e7b5f8e45a8
5
5
  SHA512:
6
- metadata.gz: 406694b1d2d9abc40f261402f385c6b2e152a6aeb18c6408616883dca850a1852d5f02317d60278391f4121116ea2eb33ce288bc089f70f4d8679e00bac54514
7
- data.tar.gz: fc1d0a961b56cc2acafcfa1e17c33b0a0d573a93c6cec814ff4fa23c9db7e604bc64e1eb6b8a8e8bbe14603929b219c8d147297ed365d0c010235a3640904283
6
+ metadata.gz: '068011e2c0d56dc7244fa15840d19751cadbefa0e940153f71c11c23b90877d0b6ed49721b79b281c2bb8cf3fcf807c4c78947be632e508f84e01ffe4b3123a0'
7
+ data.tar.gz: 9ef6af33362c317887fc25ba988bcfc58414306b83f085890b6041387bddda6c60bb11c917b79a2a6259417fbc54194764d74eceed36c0f62a0a8822b1285109
@@ -1,3 +1,5 @@
1
+ require 'concurrent-ruby'
2
+
1
3
  module RemoteFiles
2
4
  class Configuration
3
5
  attr_reader :name
@@ -6,6 +8,7 @@ module RemoteFiles
6
8
  @name = name
7
9
  @stores = []
8
10
  @stores_map = {}
11
+ @max_delete_in_parallel = config.delete(:max_delete_in_parallel) || 10
9
12
  from_hash(config)
10
13
  end
11
14
 
@@ -125,27 +128,53 @@ module RemoteFiles
125
128
  RemoteFiles.delete_file(file)
126
129
  end
127
130
 
128
- def delete_now!(file)
131
+ def delete_now!(file, parallel: false)
129
132
  exceptions = []
130
133
  stores = file.read_write_stores
131
134
 
132
135
  raise "No stores configured" if stores.empty?
133
136
 
134
- stores.each do |store|
135
- begin
136
- store.delete!(file.identifier)
137
- rescue NotFoundError => e
138
- exceptions << e
137
+ if parallel
138
+ delete_in_parallel!(file, stores, exceptions)
139
+ else
140
+ stores.each do |store|
141
+ begin
142
+ store.delete!(file.identifier)
143
+ rescue NotFoundError => e
144
+ exceptions << e
145
+ end
139
146
  end
140
147
  end
141
148
 
142
- if exceptions.size == stores.size # they all failed
143
- raise exceptions.first
144
- end
149
+ raise exceptions.first if exceptions.size == stores.size # they all failed
145
150
 
146
151
  true
147
152
  end
148
153
 
154
+ # This method is used to delete a file from all stores in parallel
155
+ # exceptions are passed back to the caller
156
+ def delete_in_parallel!(file, stores, exceptions)
157
+ pool = Concurrent::FixedThreadPool.new(@max_delete_in_parallel)
158
+
159
+ futures = stores.map do |store|
160
+ Concurrent::Promises.future_on(pool) do
161
+ begin
162
+ store.delete!(file.identifier)
163
+ rescue NotFoundError => e
164
+ e
165
+ end
166
+ end
167
+ end
168
+
169
+ futures.each do |future|
170
+ result = future.value
171
+ exceptions << result if result.is_a?(Exception)
172
+ end
173
+
174
+ pool.shutdown
175
+ pool.wait_for_termination
176
+ end
177
+
149
178
  def synchronize!(file)
150
179
  file.missing_stores.each do |store|
151
180
  next if store.read_only?
@@ -118,8 +118,8 @@ module RemoteFiles
118
118
  end
119
119
  end
120
120
 
121
- def delete_now!
122
- configuration.delete_now!(self)
121
+ def delete_now!(parallel: false)
122
+ configuration.delete_now!(self, parallel: parallel)
123
123
  end
124
124
  end
125
125
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteFiles
2
- VERSION = '3.6.0'
2
+ VERSION = '3.7.0-alpha.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.0
4
+ version: 3.7.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-17 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-aws
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
41
55
  description: A library for uploading files to multiple remote storage backends like
42
56
  Amazon S3 and Rackspace CloudFiles.
43
57
  email:
@@ -76,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
90
  - !ruby/object:Gem::Version
77
91
  version: '0'
78
92
  requirements: []
79
- rubygems_version: 3.5.9
93
+ rubygems_version: 3.5.16
80
94
  signing_key:
81
95
  specification_version: 4
82
96
  summary: The purpose of the library is to implement a simple interface for uploading