http_store 0.6.2 → 0.6.4

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: 51417dbde590057252ad4ee05aeb7229b8d8404ad363e1cc73ca55ff6e807713
4
- data.tar.gz: 1c7b3672edb4fc7b59a41da5f12631dbf362aed17558892ccf8ac26ebfa4381d
3
+ metadata.gz: c5912e7d57df1c0dbbed3edc404d103137ce8a503b36ed45d46059e1f54ff279
4
+ data.tar.gz: 27ef060e848875d2f0020124efbfbe19365b83015ab5cac188ce5d3cd9bbda68
5
5
  SHA512:
6
- metadata.gz: 65fff5fd411e35bd9ea9e2696c5264eb74a558f30fb49c65ddcea499c9701fcb59cb13074c6a55def855c3fa1e5dfb0d77caee0f993383be275746531cbb4a5e
7
- data.tar.gz: 29e554f5705231374c30a0d5907aa9f77d5effffa06685e5dc856820a2b51c90d7eb1646e8a8f8c65ffdcbc381b261cdecf898b4734c9e73353c6d38aef5efd0
6
+ metadata.gz: '01887ac6363da2fccd78ac8dbfc86360ce85feadb84a911054aea6d40eff0c49864c986600dc4cae5c6a63b74251a2d1735dbb0e43c9ba1629f1ce9101109cee'
7
+ data.tar.gz: b0e1b314ace8561d7e04a88b746e31821504f099541085aa56744eeb18c5f850760013b296ea63838ee47f64f1683286167f5f703b7dc66091b2b66c8f7f4d12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- http_store (0.6.2)
4
+ http_store (0.6.4)
5
5
  activerecord
6
6
  hashie
7
7
  rails
@@ -106,7 +106,7 @@ GEM
106
106
  i18n (1.14.1)
107
107
  concurrent-ruby (~> 1.0)
108
108
  io-console (0.7.1)
109
- irb (1.10.1)
109
+ irb (1.11.0)
110
110
  rdoc
111
111
  reline (>= 0.3.8)
112
112
  loofah (2.22.0)
@@ -124,7 +124,7 @@ GEM
124
124
  mini_mime (1.1.5)
125
125
  minitest (5.20.0)
126
126
  mutex_m (0.2.0)
127
- net-imap (0.4.8)
127
+ net-imap (0.4.9)
128
128
  date
129
129
  net-protocol
130
130
  net-pop (0.1.2)
@@ -19,16 +19,21 @@ class CreateHttpLogs < ActiveRecord::Migration[5.2]
19
19
  t.integer :status_code, comment: 'response http code'
20
20
  t.text :response, comment: 'response body'
21
21
  t.text :response_headers, comment: 'response header'
22
+ t.integer :response_code, comment: 'response code'
22
23
 
23
24
  # response checker
24
25
  t.boolean :response_valid, comment: '请求结果 true/false, 这个要根据业务逻辑来设定. 不能靠 status_code 来确定'
25
26
  t.text :response_data, comment: '格式化后的 response'
26
27
 
27
28
  # relation
28
- t.string :client_type, limit: 80, comment: '请求类型'
29
+ t.string :client_type, index: true, limit: 80, comment: '请求类型'
29
30
  t.string :requestable_id, comment: '外键 ID'
30
31
  t.string :requestable_type, comment: '外键 类型'
31
32
  t.integer :parent_id
33
+ t.boolean :is_system, default: false, comment: '是否系统请求'
34
+
35
+ t.boolean :cache_request, comment: '是否缓存请求'
36
+ t.integer :retry_times, comment: '重试次数'
32
37
 
33
38
  t.index [:created_at, :client_type]
34
39
  t.index [:created_at, :response_valid]
@@ -28,10 +28,14 @@ module HttpStore
28
28
  return unless HttpStore.config.store_enable
29
29
 
30
30
  @meta.parent_id = storeable_record.id if use_cache?
31
- @storeable_record = HttpStore.config.store_class.new(gen_storable_meta)
31
+ @storeable_record = store_class.new(gen_storable_meta)
32
32
  @storeable_record.save!
33
33
  end
34
34
 
35
+ def store_class
36
+ @store_class ||= HttpStore.config.store_class.to_s.constantize
37
+ end
38
+
35
39
  def use_cache?
36
40
  @use_cache ||= !@meta.force && storeable_record.present?
37
41
  end
@@ -31,6 +31,7 @@ module HttpStore
31
31
  http_method: request.request_method,
32
32
  data: request.params,
33
33
  client_type: request.params[:client_type],
34
+ is_system: true,
34
35
  headers: request.headers.select { |k, _v| k.start_with? 'HTTP_' }.to_h,
35
36
  query_params: request.query_parameters,
36
37
  force: true,
@@ -1,3 +1,3 @@
1
1
  module HttpStore
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.4"
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.6.2
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - black
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-20 00:00:00.000000000 Z
11
+ date: 2023-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -140,9 +140,6 @@ files:
140
140
  - bin/console
141
141
  - bin/setup
142
142
  - db/migrate/1_create_http_logs.rb
143
- - db/migrate/2_add_cache_response_field_to_http_log.rb
144
- - db/migrate/3_add_retry_times_field_to_http_log.rb
145
- - db/migrate/4_add_index_to_http_log.rb
146
143
  - http_store.gemspec
147
144
  - lib/generators/http_store/initializer_generator.rb
148
145
  - lib/http_store.rb
@@ -1,6 +0,0 @@
1
- class AddCacheResponseFieldToHttpLog < ActiveRecord::Migration[5.2]
2
- def change
3
- add_column :http_logs, :cache_response, :boolean
4
- add_column :http_logs, :response_code, :integer
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddRetryTimesFieldToHttpLog < ActiveRecord::Migration[5.2]
2
- def change
3
- add_column :http_logs, :retry_times, :integer
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddIndexToHttpLog < ActiveRecord::Migration[5.2]
2
- def change
3
- add_index :http_logs, :client_type
4
- end
5
- end