http_store 0.3.22 → 0.3.27

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: a6861b1ab065bdf7cd09eba47888a353164d0b9ab9d114204908e73b0b4bc6e7
4
- data.tar.gz: 4f283da493a1fc04ee9788e88e40ca61fe164c3d05cdff2417ff402afe29e18b
3
+ metadata.gz: 7cc91ad9365c637335d13765b25ba447ed1a276c4a6c66f8603c32bf6d2b5418
4
+ data.tar.gz: 71ec1e92654374c34c9ad67ff7a93a040273e785e977f695a02c3a24ad5e5be2
5
5
  SHA512:
6
- metadata.gz: 824835258a3b4837e8bdf9615e63efab5ea4ae3670daecb4e85f594ed65b16f7250199b21e9cda0b1566bf872b8c33d6fa29f081f11058b3948ad42b98ba8a03
7
- data.tar.gz: 13606e6d3791edbae8cb345f7a73efc9de3c66572fa1416b682ed221334e10369a6a9c5528938464032a96400e83cc788d0ee3dafa4521bd9b476acced09cfdd
6
+ metadata.gz: da2f2c67fdcd6453069f0c31d681d95595ca5223631b176c104af32878a09c2c676caff1f1ce06d298728dc0aac3e9547892589cc7467fec7d760ad35d3914f8
7
+ data.tar.gz: e09d0deae789314dde1187fc39ad0835f69faa7fd3bdbab2d4d69e1a8b106740f9bd5be11c26d3fd82aab87aa2aa08d6b3fb174e8366117a1abd3a83a61a8f25
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_store (0.3.22)
4
+ http_store (0.3.27)
5
5
  activerecord (>= 5.0, < 6.1)
6
6
  hashie (~> 3.0)
7
7
  rails (>= 5, < 7)
@@ -10,110 +10,125 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- actioncable (5.2.3)
14
- actionpack (= 5.2.3)
13
+ actioncable (6.0.3.1)
14
+ actionpack (= 6.0.3.1)
15
15
  nio4r (~> 2.0)
16
16
  websocket-driver (>= 0.6.1)
17
- actionmailer (5.2.3)
18
- actionpack (= 5.2.3)
19
- actionview (= 5.2.3)
20
- activejob (= 5.2.3)
17
+ actionmailbox (6.0.3.1)
18
+ actionpack (= 6.0.3.1)
19
+ activejob (= 6.0.3.1)
20
+ activerecord (= 6.0.3.1)
21
+ activestorage (= 6.0.3.1)
22
+ activesupport (= 6.0.3.1)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.0.3.1)
25
+ actionpack (= 6.0.3.1)
26
+ actionview (= 6.0.3.1)
27
+ activejob (= 6.0.3.1)
21
28
  mail (~> 2.5, >= 2.5.4)
22
29
  rails-dom-testing (~> 2.0)
23
- actionpack (5.2.3)
24
- actionview (= 5.2.3)
25
- activesupport (= 5.2.3)
26
- rack (~> 2.0)
30
+ actionpack (6.0.3.1)
31
+ actionview (= 6.0.3.1)
32
+ activesupport (= 6.0.3.1)
33
+ rack (~> 2.0, >= 2.0.8)
27
34
  rack-test (>= 0.6.3)
28
35
  rails-dom-testing (~> 2.0)
29
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
- actionview (5.2.3)
31
- activesupport (= 5.2.3)
36
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
37
+ actiontext (6.0.3.1)
38
+ actionpack (= 6.0.3.1)
39
+ activerecord (= 6.0.3.1)
40
+ activestorage (= 6.0.3.1)
41
+ activesupport (= 6.0.3.1)
42
+ nokogiri (>= 1.8.5)
43
+ actionview (6.0.3.1)
44
+ activesupport (= 6.0.3.1)
32
45
  builder (~> 3.1)
33
46
  erubi (~> 1.4)
34
47
  rails-dom-testing (~> 2.0)
35
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
36
- activejob (5.2.3)
37
- activesupport (= 5.2.3)
48
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
+ activejob (6.0.3.1)
50
+ activesupport (= 6.0.3.1)
38
51
  globalid (>= 0.3.6)
39
- activemodel (5.2.3)
40
- activesupport (= 5.2.3)
41
- activerecord (5.2.3)
42
- activemodel (= 5.2.3)
43
- activesupport (= 5.2.3)
44
- arel (>= 9.0)
45
- activestorage (5.2.3)
46
- actionpack (= 5.2.3)
47
- activerecord (= 5.2.3)
52
+ activemodel (6.0.3.1)
53
+ activesupport (= 6.0.3.1)
54
+ activerecord (6.0.3.1)
55
+ activemodel (= 6.0.3.1)
56
+ activesupport (= 6.0.3.1)
57
+ activestorage (6.0.3.1)
58
+ actionpack (= 6.0.3.1)
59
+ activejob (= 6.0.3.1)
60
+ activerecord (= 6.0.3.1)
48
61
  marcel (~> 0.3.1)
49
- activesupport (5.2.3)
62
+ activesupport (6.0.3.1)
50
63
  concurrent-ruby (~> 1.0, >= 1.0.2)
51
64
  i18n (>= 0.7, < 2)
52
65
  minitest (~> 5.1)
53
66
  tzinfo (~> 1.1)
54
- arel (9.0.0)
55
- builder (3.2.3)
67
+ zeitwerk (~> 2.2, >= 2.2.2)
68
+ builder (3.2.4)
56
69
  byebug (11.0.1)
57
- concurrent-ruby (1.1.5)
58
- crass (1.0.4)
70
+ concurrent-ruby (1.1.6)
71
+ crass (1.0.6)
59
72
  diff-lcs (1.3)
60
73
  domain_name (0.5.20190701)
61
74
  unf (>= 0.0.5, < 1.0.0)
62
- erubi (1.8.0)
75
+ erubi (1.9.0)
63
76
  globalid (0.4.2)
64
77
  activesupport (>= 4.2.0)
65
78
  hashie (3.6.0)
66
79
  http-accept (1.7.0)
67
80
  http-cookie (1.0.3)
68
81
  domain_name (~> 0.5)
69
- i18n (1.6.0)
82
+ i18n (1.8.2)
70
83
  concurrent-ruby (~> 1.0)
71
- loofah (2.2.3)
84
+ loofah (2.5.0)
72
85
  crass (~> 1.0.2)
73
86
  nokogiri (>= 1.5.9)
74
87
  mail (2.7.1)
75
88
  mini_mime (>= 0.1.1)
76
89
  marcel (0.3.3)
77
90
  mimemagic (~> 0.3.2)
78
- method_source (0.9.2)
79
- mime-types (3.3)
91
+ method_source (1.0.0)
92
+ mime-types (3.3.1)
80
93
  mime-types-data (~> 3.2015)
81
- mime-types-data (3.2019.1009)
82
- mimemagic (0.3.3)
94
+ mime-types-data (3.2020.0425)
95
+ mimemagic (0.3.5)
83
96
  mini_mime (1.0.2)
84
97
  mini_portile2 (2.4.0)
85
- minitest (5.11.3)
98
+ minitest (5.14.1)
86
99
  netrc (0.11.0)
87
- nio4r (2.5.1)
88
- nokogiri (1.10.4)
100
+ nio4r (2.5.2)
101
+ nokogiri (1.10.9)
89
102
  mini_portile2 (~> 2.4.0)
90
- rack (2.0.7)
103
+ rack (2.2.2)
91
104
  rack-test (1.1.0)
92
105
  rack (>= 1.0, < 3)
93
- rails (5.2.3)
94
- actioncable (= 5.2.3)
95
- actionmailer (= 5.2.3)
96
- actionpack (= 5.2.3)
97
- actionview (= 5.2.3)
98
- activejob (= 5.2.3)
99
- activemodel (= 5.2.3)
100
- activerecord (= 5.2.3)
101
- activestorage (= 5.2.3)
102
- activesupport (= 5.2.3)
106
+ rails (6.0.3.1)
107
+ actioncable (= 6.0.3.1)
108
+ actionmailbox (= 6.0.3.1)
109
+ actionmailer (= 6.0.3.1)
110
+ actionpack (= 6.0.3.1)
111
+ actiontext (= 6.0.3.1)
112
+ actionview (= 6.0.3.1)
113
+ activejob (= 6.0.3.1)
114
+ activemodel (= 6.0.3.1)
115
+ activerecord (= 6.0.3.1)
116
+ activestorage (= 6.0.3.1)
117
+ activesupport (= 6.0.3.1)
103
118
  bundler (>= 1.3.0)
104
- railties (= 5.2.3)
119
+ railties (= 6.0.3.1)
105
120
  sprockets-rails (>= 2.0.0)
106
121
  rails-dom-testing (2.0.3)
107
122
  activesupport (>= 4.2.0)
108
123
  nokogiri (>= 1.6)
109
- rails-html-sanitizer (1.2.0)
110
- loofah (~> 2.2, >= 2.2.2)
111
- railties (5.2.3)
112
- actionpack (= 5.2.3)
113
- activesupport (= 5.2.3)
124
+ rails-html-sanitizer (1.3.0)
125
+ loofah (~> 2.3)
126
+ railties (6.0.3.1)
127
+ actionpack (= 6.0.3.1)
128
+ activesupport (= 6.0.3.1)
114
129
  method_source
115
130
  rake (>= 0.8.7)
116
- thor (>= 0.19.0, < 2.0)
131
+ thor (>= 0.20.3, < 2.0)
117
132
  rake (10.5.0)
118
133
  rest-client (2.1.0)
119
134
  http-accept (>= 1.7.0, < 2.0)
@@ -133,23 +148,24 @@ GEM
133
148
  diff-lcs (>= 1.2.0, < 2.0)
134
149
  rspec-support (~> 3.8.0)
135
150
  rspec-support (3.8.2)
136
- sprockets (3.7.2)
151
+ sprockets (4.0.0)
137
152
  concurrent-ruby (~> 1.0)
138
153
  rack (> 1, < 3)
139
154
  sprockets-rails (3.2.1)
140
155
  actionpack (>= 4.0)
141
156
  activesupport (>= 4.0)
142
157
  sprockets (>= 3.0.0)
143
- thor (0.20.3)
158
+ thor (1.0.1)
144
159
  thread_safe (0.3.6)
145
- tzinfo (1.2.5)
160
+ tzinfo (1.2.7)
146
161
  thread_safe (~> 0.1)
147
162
  unf (0.1.4)
148
163
  unf_ext
149
- unf_ext (0.0.7.6)
164
+ unf_ext (0.0.7.7)
150
165
  websocket-driver (0.7.1)
151
166
  websocket-extensions (>= 0.1.0)
152
167
  websocket-extensions (0.1.4)
168
+ zeitwerk (2.3.0)
153
169
 
154
170
  PLATFORMS
155
171
  ruby
@@ -162,4 +178,4 @@ DEPENDENCIES
162
178
  rspec (~> 3.0)
163
179
 
164
180
  BUNDLED WITH
165
- 2.0.2
181
+ 2.1.4
@@ -0,0 +1,5 @@
1
+ class AddRetryTimesFieldToHttpLog < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :http_logs, :retry_times, :boolean
4
+ end
5
+ end
@@ -8,7 +8,7 @@ require 'http_store/engine'
8
8
  module HttpStore
9
9
  extend ActiveSupport::Autoload
10
10
 
11
- REQUEST_KEYS = %w[http_method url data_type headers query_params data other_params force request_valid]
11
+ REQUEST_KEYS = %w[http_method url data_type headers query_params data other_params force request_valid retry_times]
12
12
  RESPONSE_KEYS = %w[status_code response response_headers response_data response_valid response_code cache_response]
13
13
  META_KEYS = %w[request_digest client_type parent_id requestable_id requestable_type]
14
14
  TMP_KEYS = %w[requestable response_obj]
@@ -15,17 +15,19 @@ module HttpStore
15
15
  build_request
16
16
 
17
17
  return unless request_valid?
18
-
19
- # exist request or not force, return
20
18
  load_storeable_record and return if use_cache?
21
19
 
22
20
  execute # send request
23
- raise HttpStore::RequestError, 'response_obj is nil' if response_obj.nil?
21
+ retry! while need_retry? && retry_times.to_i > 0
24
22
 
25
- build_response
26
23
  after_response
27
- ensure
28
- store_request
24
+ end
25
+
26
+ def retry!
27
+ @meta.retry_times = retry_times.to_i - 1
28
+ @meta.force = true
29
+
30
+ execute
29
31
  end
30
32
 
31
33
  HttpStore::ALL_KEYS.each do |meta_key|
@@ -47,6 +49,11 @@ module HttpStore
47
49
 
48
50
  def execute
49
51
  @meta.response_obj = get? ? http_get_execute : http_post_execute
52
+ raise HttpStore::RequestError, 'response_obj is nil' if response_obj.nil?
53
+
54
+ build_response
55
+ ensure
56
+ store_request
50
57
  end
51
58
 
52
59
  def http_get_execute
@@ -6,6 +6,10 @@ module HttpStore
6
6
  status_code >= 200 && status_code < 400
7
7
  end
8
8
 
9
+ def need_retry?
10
+ !response_valid?
11
+ end
12
+
9
13
  def json_response?
10
14
  response_headers_hash['content_type'].to_s =~ /json/
11
15
  end
@@ -28,9 +28,6 @@ module HttpStore
28
28
  @meta.parent_id = storeable_record.id if use_cache?
29
29
  @storeable_record = HttpStore.config.store_class.new(gen_storable_meta)
30
30
  @storeable_record.save!
31
- rescue ActiveRecord::StatementInvalid
32
- @storeable_record.response = Digest::SHA1.hexdigest(@storeable_record.response)
33
- @storeable_record.save!
34
31
  end
35
32
 
36
33
  def use_cache?
@@ -68,8 +65,9 @@ module HttpStore
68
65
  end
69
66
 
70
67
  def storable_string(str)
71
- str = str.clone.encode('UTF-8')
68
+ str = str.dup.force_encoding("UTF-8")
72
69
  raise EncodingError unless str.encoding.name == 'UTF-8'
70
+ raise EncodingError unless str.valid_encoding?
73
71
 
74
72
  str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..1000] } : str
75
73
  rescue EncodingError
@@ -1,3 +1,3 @@
1
1
  module HttpStore
2
- VERSION = "0.3.22"
2
+ VERSION = "0.3.27"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.22
4
+ version: 0.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - black
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -153,6 +153,7 @@ files:
153
153
  - bin/setup
154
154
  - db/migrate/1_create_http_logs.rb
155
155
  - db/migrate/2_add_cache_response_field_to_http_log.rb
156
+ - db/migrate/3_add_retry_times_field_to_http_log.rb
156
157
  - http_store.gemspec
157
158
  - lib/generators/http_store/initializer_generator.rb
158
159
  - lib/http_store.rb
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  - !ruby/object:Gem::Version
187
188
  version: '0'
188
189
  requirements: []
189
- rubygems_version: 3.0.4
190
+ rubygems_version: 3.0.8
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: store the http request, it based on rest-client