http_store 0.3.24 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +80 -64
- data/db/migrate/3_add_retry_times_field_to_http_log.rb +5 -0
- data/lib/http_store.rb +1 -1
- data/lib/http_store/client.rb +13 -6
- data/lib/http_store/helpers/responseable.rb +4 -0
- data/lib/http_store/helpers/storable.rb +6 -10
- data/lib/http_store/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e21b78e87d29ba5cc7dda5c373c0c795c5ad497a7e50657079055b6d711cbf7c
|
4
|
+
data.tar.gz: 51a2b9c79ed2ec24db30a08aa27692cce94209176e86f35fef42964467f99766
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e2511f353ba3cec16b15452daef6d817f0698c44662ed56463f4f7466d8649c0235e907c70c92310ac4f385e174bf570bdc19ee4ad1683ccaa3bf0878809dc7
|
7
|
+
data.tar.gz: 845a31ef1c6579a82d129f9d615a79565aee3d5460429d178c516c7d3ba5ee18d1a5a0285b07d92ac4cf8bedddcd4b720fa224bfad52f6ee87c8b8395971995b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
http_store (0.
|
4
|
+
http_store (0.5.1)
|
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 (
|
14
|
-
actionpack (=
|
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
|
-
|
18
|
-
actionpack (=
|
19
|
-
|
20
|
-
|
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 (
|
24
|
-
actionview (=
|
25
|
-
activesupport (=
|
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
|
30
|
-
|
31
|
-
|
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.
|
36
|
-
activejob (
|
37
|
-
activesupport (=
|
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 (
|
40
|
-
activesupport (=
|
41
|
-
activerecord (
|
42
|
-
activemodel (=
|
43
|
-
activesupport (=
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
activerecord (=
|
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 (
|
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
|
-
|
55
|
-
builder (3.2.
|
67
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
68
|
+
builder (3.2.4)
|
56
69
|
byebug (11.0.1)
|
57
|
-
concurrent-ruby (1.1.
|
58
|
-
crass (1.0.
|
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.
|
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.
|
82
|
+
i18n (1.8.2)
|
70
83
|
concurrent-ruby (~> 1.0)
|
71
|
-
loofah (2.
|
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.
|
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.
|
82
|
-
mimemagic (0.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.
|
98
|
+
minitest (5.14.1)
|
86
99
|
netrc (0.11.0)
|
87
|
-
nio4r (2.5.
|
88
|
-
nokogiri (1.10.
|
100
|
+
nio4r (2.5.2)
|
101
|
+
nokogiri (1.10.9)
|
89
102
|
mini_portile2 (~> 2.4.0)
|
90
|
-
rack (2.
|
103
|
+
rack (2.2.2)
|
91
104
|
rack-test (1.1.0)
|
92
105
|
rack (>= 1.0, < 3)
|
93
|
-
rails (
|
94
|
-
actioncable (=
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
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 (=
|
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.
|
110
|
-
loofah (~> 2.
|
111
|
-
railties (
|
112
|
-
actionpack (=
|
113
|
-
activesupport (=
|
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.
|
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 (
|
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.
|
158
|
+
thor (1.0.1)
|
144
159
|
thread_safe (0.3.6)
|
145
|
-
tzinfo (1.2.
|
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.
|
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.
|
181
|
+
2.1.4
|
data/lib/http_store.rb
CHANGED
@@ -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]
|
data/lib/http_store/client.rb
CHANGED
@@ -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
|
-
|
21
|
+
retry! while need_retry? && retry_times.to_i > 0
|
24
22
|
|
25
|
-
build_response
|
26
23
|
after_response
|
27
|
-
|
28
|
-
|
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
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module HttpStore
|
2
2
|
module Helpers
|
3
3
|
module Storable
|
4
|
-
STRING_LIMIT_SIZE =
|
4
|
+
STRING_LIMIT_SIZE = 1000
|
5
|
+
TEXT_LIMIT_SIZE = 10000
|
5
6
|
|
6
7
|
def storeable_record
|
7
8
|
return unless HttpStore.config.store_enable
|
@@ -28,11 +29,6 @@ module HttpStore
|
|
28
29
|
@meta.parent_id = storeable_record.id if use_cache?
|
29
30
|
@storeable_record = HttpStore.config.store_class.new(gen_storable_meta)
|
30
31
|
@storeable_record.save!
|
31
|
-
rescue ActiveRecord::StatementInvalid
|
32
|
-
debugger
|
33
|
-
|
34
|
-
@storeable_record.response = Digest::SHA1.hexdigest(@storeable_record.response)
|
35
|
-
@storeable_record.save!
|
36
32
|
end
|
37
33
|
|
38
34
|
def use_cache?
|
@@ -44,11 +40,11 @@ module HttpStore
|
|
44
40
|
storable_v = storable(v)
|
45
41
|
|
46
42
|
begin
|
47
|
-
storable_v = storable_v.to_json[0..
|
43
|
+
storable_v = storable_v.to_json[0..TEXT_LIMIT_SIZE] if v.is_a?(Hash) || v.is_a?(Array)
|
48
44
|
|
49
45
|
[k, storable_v]
|
50
46
|
rescue JSON::GeneratorError
|
51
|
-
[k, storable_v.to_s[0..
|
47
|
+
[k, storable_v.to_s[0..TEXT_LIMIT_SIZE]]
|
52
48
|
end
|
53
49
|
end.to_h
|
54
50
|
end
|
@@ -70,11 +66,11 @@ module HttpStore
|
|
70
66
|
end
|
71
67
|
|
72
68
|
def storable_string(str)
|
73
|
-
str = str.
|
69
|
+
str = str.dup.force_encoding("UTF-8")
|
74
70
|
raise EncodingError unless str.encoding.name == 'UTF-8'
|
75
71
|
raise EncodingError unless str.valid_encoding?
|
76
72
|
|
77
|
-
str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..
|
73
|
+
str.length > STRING_LIMIT_SIZE ? { digest: Digest::SHA1.hexdigest(str), origin: str[0..STRING_LIMIT_SIZE] } : str
|
78
74
|
rescue EncodingError
|
79
75
|
{ digest: Digest::SHA1.hexdigest(str) }
|
80
76
|
end
|
data/lib/http_store/version.rb
CHANGED
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.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- black
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-20 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.
|
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
|