api_header_optimizer 0.1.1 → 0.1.3

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: e08e6943ab506fcbb3a6291b5029aeae8b6e492289c69e381b1dd3e4c2b0736b
4
- data.tar.gz: d98223a148a2f61d8b5b33d046acafe35e24a7f0b4f6f48ac11348b331820c27
3
+ metadata.gz: a87ceb1aa38cc621dedcc2e2c72c5d06af166e58bd96939899e544ef00517d4b
4
+ data.tar.gz: 8491e6f127bebc4b3117c1ecacfea0ef5673933f65eb3f1ed2ea0accc4ecef39
5
5
  SHA512:
6
- metadata.gz: b24e481b9b05036c70a187df5d7d2697308251c111a2d2bcd5db8eeec7e98ef14daf0767142c8de7cd6f5efe2958b43b7dc10e87c4be190a08e7ef1195a76e86
7
- data.tar.gz: 3da59497ec38a9046a750a1648926e784fe4639ed5a17ec9ca7c528a0fd7dbc896f8db12f6b0ba23a99c718e1bea4c7b7eedb3c80232be4d4114eb2e72e73c77
6
+ metadata.gz: 2217d1708db46c38b0e9d17a8b21d48e2386ce4d8b2215a486c2f96b6e56dd9f41605a4add169dc60825cfd0c27b38c6ab2b5ec20d2a7c5810e5dd2473c2be8b
7
+ data.tar.gz: a576ddedead1b03922f0b0a696b83f44fd44593d32f98ff1a635a04bea1f8ea8f7cb121f54f033f7b5b12bab732804218794fdb6583820e3c79bdb2d2b4b362c
@@ -9,25 +9,35 @@ module ApiHeaderOptimizer
9
9
  @uri = URI(uri)
10
10
  @all_headers = all_headers
11
11
  @results = []
12
+ @mutex = Mutex.new # Erişim problemlerini önlemek için mutex kullanıyoruz
12
13
  end
13
14
 
14
15
  # Tek bir header seti ile istek yapar ve sonucu kontrol eder
15
16
  def test_header_set(header_set)
16
17
  response = make_request(header_set)
17
18
  return unless response # İstek başarısızsa geç
18
- @results << { headers: header_set, code: response.code, body: response.body }
19
+
20
+ # Sonuçları güvenli bir şekilde eklemek için mutex kullanıyoruz
21
+ @mutex.synchronize do
22
+ @results << { headers: header_set, code: response.code, body: response.body }
23
+ end
19
24
  end
20
25
 
21
26
  # Header kombinasyonlarını test eder
22
27
  def test_combinations
23
- # Tüm header kombinasyonlarını oluştur ve test et
24
28
  header_keys = @all_headers.keys
25
29
  subsets = ApiHeaderOptimizer::Helpers.subsets(header_keys)
26
30
 
27
- subsets.each do |subset|
28
- header_set = subset.to_h { |key| [key, @all_headers[key]] }
29
- test_header_set(header_set)
31
+ # Eşzamanlılık için thread'ler oluşturuyoruz
32
+ threads = subsets.map do |subset|
33
+ Thread.new do
34
+ header_set = subset.to_h { |key| [key, @all_headers[key]] }
35
+ test_header_set(header_set)
36
+ end
30
37
  end
38
+
39
+ # Tüm thread'lerin bitmesini bekliyoruz
40
+ threads.each(&:join)
31
41
  end
32
42
 
33
43
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ApiHeaderOptimizer
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_header_optimizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ziya Gökalp