relaton 1.9.5 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/docs/README.adoc +1 -0
  3. data/lib/relaton/db.rb +2 -1
  4. data/lib/relaton/version.rb +1 -1
  5. data/lib/relaton/workers_pool.rb +3 -3
  6. data/spec/relaton/db_spec.rb +10 -0
  7. data/spec/vcr_cassetes/async_fetch.yml +1370 -1370
  8. data/spec/vcr_cassetes/bsi_bs_en_iso_8848.yml +10 -10
  9. data/spec/vcr_cassetes/cc_dir_10005_2019.yml +14 -14
  10. data/spec/vcr_cassetes/cen_en_10160_1999.yml +29 -29
  11. data/spec/vcr_cassetes/cie_001_1980.yml +7 -7
  12. data/spec/vcr_cassetes/ecma_6.yml +7 -7
  13. data/spec/vcr_cassetes/fisp_140.yml +6 -6
  14. data/spec/vcr_cassetes/gb_t_20223_2006.yml +8 -8
  15. data/spec/vcr_cassetes/iana_service_names_port_numbers.yml +10 -10
  16. data/spec/vcr_cassetes/iec_60050_102_2007.yml +27 -27
  17. data/spec/vcr_cassetes/iec_combined_included.yml +94 -92
  18. data/spec/vcr_cassetes/ieee_528_2019.yml +14 -14
  19. data/spec/vcr_cassetes/iho_b_11.yml +7 -7
  20. data/spec/vcr_cassetes/iso_111111119115_1.yml +2 -2
  21. data/spec/vcr_cassetes/iso_19115_1.yml +15 -15
  22. data/spec/vcr_cassetes/iso_19115_1_2.yml +32 -32
  23. data/spec/vcr_cassetes/iso_19115_all_parts.yml +15 -15
  24. data/spec/vcr_cassetes/iso_19133_2005.yml +15 -15
  25. data/spec/vcr_cassetes/iso_cd_14093.yml +13 -13
  26. data/spec/vcr_cassetes/iso_combined_applied.yml +31 -31
  27. data/spec/vcr_cassetes/iso_combined_included.yml +29 -29
  28. data/spec/vcr_cassetes/itu_combined_included.yml +168 -168
  29. data/spec/vcr_cassetes/ogc_19_025r1.yml +7 -7
  30. data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +4 -4
  31. data/spec/vcr_cassetes/rfc_8341.yml +7 -7
  32. data/spec/vcr_cassetes/sp_800_38b.yml +6 -6
  33. data/spec/vcr_cassetes/threads_from_env.yml +448 -0
  34. data/spec/vcr_cassetes/un_rtade_cefact_2004_32.yml +30 -30
  35. data/spec/vcr_cassetes/w3c_json_ld11.yml +9 -9
  36. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d130b4485dbbf753e79494a4d586acf8fd85df120d4e2f1f35aa5c7380e05811
4
- data.tar.gz: 1872fc4d88f29de709f81dfca39132d1c7fb244b9069661d8c7c4bca70a80977
3
+ metadata.gz: '0856681e37a3dfb7fef7e84084c49990f4f980efcdf2bd3be6e019c9baf8c3e6'
4
+ data.tar.gz: 9c53c38d1b422435f5969ce02f7bee7b05d1195e57b0526a958a83abcaf2eea6
5
5
  SHA512:
6
- metadata.gz: 1209e92a74b33acc54fcc1f391ec4beb1833cb2886375188f16ff8feb6c7c12c6f2e56978b3a77b442599fafa5bfbc4b4edfec6305e422afdb97cbc3e07190a0
7
- data.tar.gz: f5a8c37e80afa5b80d7779735d54f685e9ba85a2bea6acd2ad3a4608b4e74d75c76248b6989af7df05df1f50f975b0ab85397355c90c2c2f50bc00159fc7d5fe
6
+ metadata.gz: fc981fcd5df1fc7de922df2a2e979963d26ef784e4a6bc88448a632a8b09a0483292edbd2ecbe70caa129d59a7c9254c95c9307d01bd5dba6d0e28cd17832fbb
7
+ data.tar.gz: 27cb0dd8f208880222fdc4d8960ef644ca9ec1b1ed678621807ca319fe0596e7a560815c78504b4ebd4de35198f91a054125e5632273a068d44781abfa62a65e
data/docs/README.adoc CHANGED
@@ -178,6 +178,7 @@ x = db.fetch_db("ISO 5749")
178
178
  => nil
179
179
 
180
180
  # Fetching asynchronously
181
+ # RELATON_FETCH_PARALLEL environment variable can be used to ovveride default number of parallel fetches
181
182
 
182
183
  # prepare queue for results
183
184
  results = Queue.new
data/lib/relaton/db.rb CHANGED
@@ -105,7 +105,8 @@ module Relaton
105
105
  if stdclass
106
106
  unless @queues[stdclass]
107
107
  processor = @registry.processors[stdclass]
108
- wp = WorkersPool.new(processor.threads) do |args|
108
+ threads = ENV["RELATON_FETCH_PARALLEL"]&.to_i || processor.threads
109
+ wp = WorkersPool.new(threads) do |args|
109
110
  args[3].call fetch(*args[0..2])
110
111
  rescue RelatonBib::RequestError => e
111
112
  args[3].call e
@@ -1,3 +1,3 @@
1
1
  module Relaton
2
- VERSION = "1.9.5".freeze
2
+ VERSION = "1.9.6".freeze
3
3
  end
@@ -4,9 +4,9 @@ module Relaton
4
4
  # Workers poll.
5
5
  class WorkersPool
6
6
  def initialize(workers = 2, &_block)
7
- num_workers = workers < 2 ? 2 : workers
8
- @queue = SizedQueue.new(num_workers * 2)
9
- @threads = Array.new num_workers do
7
+ # num_workers = workers < 2 ? 2 : workers
8
+ @queue = SizedQueue.new(workers * 2)
9
+ @threads = Array.new workers do
10
10
  Thread.new do
11
11
  while item = @queue.pop; yield(item) end
12
12
  end
@@ -184,6 +184,16 @@ RSpec.describe Relaton::Db do
184
184
  end
185
185
  expect(result).to be_nil
186
186
  end
187
+
188
+ it "use threads number from RELATON_FETCH_PARALLEL" do
189
+ expect(ENV).to receive(:[]).with("RELATON_FETCH_PARALLEL").and_return(1)
190
+ allow(ENV).to receive(:[]).and_call_original
191
+ expect(Relaton::WorkersPool).to receive(:new).with(1).and_call_original
192
+ VCR.use_cassette "threads_from_env" do
193
+ db.fetch_async("ITU-T G.993.5") { |r| queue << r }
194
+ Timeout.timeout(5) { queue.pop }
195
+ end
196
+ end
187
197
  end
188
198
 
189
199
  context "fetch documents form static cache" do