istox 0.1.157.8.1 → 0.1.158.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/istox.rb +6 -0
- data/lib/istox/consumers/blockchain_status_handler.rb +6 -1
- data/lib/istox/helpers/blockchain_service.rb +4 -3
- data/lib/istox/helpers/integration_test/grpc_client_interceptor.rb +22 -0
- data/lib/istox/helpers/integration_test/grpc_server_interceptor.rb +31 -0
- data/lib/istox/helpers/integration_test/rabbitmq_consumer_interceptor.rb +32 -0
- data/lib/istox/helpers/integration_test/rabbitmq_publisher_interceptor.rb +14 -0
- data/lib/istox/helpers/integration_test/settings.rb +11 -0
- data/lib/istox/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97f303881190d40e32795203028cfc7e21c68a5e34f4240c63f09cacbc116ee5
|
4
|
+
data.tar.gz: '01196f2df3a75a91f969d04585b0683176d3624e5bb14894be61074025f33fbe'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 349210e9975fde52b911856fae0602bd92d55a2350a809bc6e6f8bf59f2fa9d47b43b5a9f88ddc2c0e57b4cea7eb5bc4be90b9a817155cd606b72b37e4bdbf5d
|
7
|
+
data.tar.gz: b4c3249825bf6eb114ce7d8d40ed3265b422b258722c449991b2eecc2b30e1b6ac98de6035730294f0c328465f4c640dafa7e6b7426a7e2652a256246927f11e
|
data/lib/istox.rb
CHANGED
@@ -45,6 +45,12 @@ module Istox
|
|
45
45
|
require 'istox/helpers/xray/rabbitmq_consumer_interceptor'
|
46
46
|
require 'istox/helpers/xray/xray_initializer'
|
47
47
|
|
48
|
+
require 'istox/helpers/integration_test/grpc_client_interceptor'
|
49
|
+
require 'istox/helpers/integration_test/grpc_server_interceptor'
|
50
|
+
require 'istox/helpers/integration_test/rabbitmq_publisher_interceptor'
|
51
|
+
require 'istox/helpers/integration_test/rabbitmq_consumer_interceptor'
|
52
|
+
require 'istox/helpers/integration_test/settings'
|
53
|
+
|
48
54
|
require 'istox/models/blockchain_receipt'
|
49
55
|
require 'istox/models/concerns/blockchain_receipt_query'
|
50
56
|
require 'istox/consumers/blockchain_status_handler'
|
@@ -26,7 +26,12 @@ module Istox
|
|
26
26
|
txhash: transaction.txn_hashes.present? ? transaction.txn_hashes.join(',') : nil)
|
27
27
|
|
28
28
|
resource = begin
|
29
|
-
class_eval("::#{receipt.resource_name}", __FILE__, __LINE__)
|
29
|
+
cls = class_eval("::#{receipt.resource_name}", __FILE__, __LINE__)
|
30
|
+
if cls.respond_to?('with_deleted')
|
31
|
+
cls.with_deleted.find(receipt.resource_id)
|
32
|
+
else
|
33
|
+
cls.find(receipt.resource_id)
|
34
|
+
end
|
30
35
|
rescue NameError
|
31
36
|
log.warn "Transaction bind to #{receipt.resource_name} with id #{receipt.resource_id} class not found, skipping..."
|
32
37
|
return
|
@@ -8,8 +8,8 @@ module Istox
|
|
8
8
|
@@blockchain_receipt_klass
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.request(sid:, action:, before:, execute:)
|
12
|
-
start(sid: sid, action: action, before: before, execute: execute, is_request: true)
|
11
|
+
def self.request(sid:, action:, before:, execute:, request_reason: nil)
|
12
|
+
start(sid: sid, action: action, before: before, execute: execute, is_request: true, request_reason: request_reason)
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.run(sid:, action:, before:, execute:)
|
@@ -19,7 +19,7 @@ module Istox
|
|
19
19
|
private
|
20
20
|
|
21
21
|
# before is the proc that will be executed before, must return the main model blockchain receipt will bind to
|
22
|
-
def start(sid:, action:, before:, execute:, is_request: false)
|
22
|
+
def start(sid:, action:, before:, execute:, is_request: false, request_reason: nil)
|
23
23
|
# create blockchain receipt first
|
24
24
|
klass = blockchain_receipt_class
|
25
25
|
uuid = ::SecureRandom.uuid
|
@@ -27,6 +27,7 @@ module Istox
|
|
27
27
|
txid: uuid,
|
28
28
|
sid: sid,
|
29
29
|
is_request: is_request,
|
30
|
+
request_reason: request_reason,
|
30
31
|
resource_action: action
|
31
32
|
)
|
32
33
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'istox/helpers/logger'
|
2
|
+
|
3
|
+
module Istox
|
4
|
+
module IntegrationTest
|
5
|
+
class GrpcClientInterceptor < ::Gruf::Interceptors::ClientInterceptor
|
6
|
+
def call(request_context:)
|
7
|
+
request_context.metadata[:integration_test] = if ::Istox::IntegrationTest::Settings.enable
|
8
|
+
'1'
|
9
|
+
else
|
10
|
+
'0'
|
11
|
+
end
|
12
|
+
|
13
|
+
result = yield
|
14
|
+
|
15
|
+
result
|
16
|
+
rescue StandardError => e
|
17
|
+
log.error e
|
18
|
+
raise e
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'istox/helpers/logger'
|
2
|
+
|
3
|
+
module Istox
|
4
|
+
module IntegrationTest
|
5
|
+
class GrpcServerInterceptor < ::Gruf::Interceptors::ServerInterceptor
|
6
|
+
def call
|
7
|
+
meta = request.active_call.metadata
|
8
|
+
enable_integration = (meta['integration_test'] if meta.present? && meta.key?('integration_test'))
|
9
|
+
|
10
|
+
if enable_integration == '1'
|
11
|
+
::Istox::IntegrationTest::Settings.enable = true
|
12
|
+
if ActiveRecord::Base.connection.current_database != Rails.configuration.database_configuration['integration']['database']
|
13
|
+
ActiveRecord::Base.establish_connection(:integration)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
::Istox::IntegrationTest::Settings.enable = false
|
17
|
+
if ActiveRecord::Base.connection.current_database != Rails.configuration.database_configuration['development']['database']
|
18
|
+
ActiveRecord::Base.establish_connection(:development)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
result = yield # this returns the protobuf message
|
23
|
+
|
24
|
+
result
|
25
|
+
rescue StandardError => e
|
26
|
+
log.error e
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'istox/helpers/logger'
|
2
|
+
|
3
|
+
module Istox
|
4
|
+
module IntegrationTest
|
5
|
+
class RabbitmqConsumerInterceptor
|
6
|
+
def call(payload, _metadata, _delivery_info)
|
7
|
+
payload_hash = payload.to_h
|
8
|
+
|
9
|
+
enable_integration_test = (payload_hash[:istox_integration_test] if payload_hash.key?(:istox_integration_test))
|
10
|
+
|
11
|
+
if enable_integration_test == '1'
|
12
|
+
::Istox::IntegrationTest::Settings.enable = true
|
13
|
+
if ActiveRecord::Base.connection.current_database != Rails.configuration.database_configuration['integration']['database']
|
14
|
+
ActiveRecord::Base.establish_connection(:integration)
|
15
|
+
end
|
16
|
+
else
|
17
|
+
::Istox::IntegrationTest::Settings.enable = false
|
18
|
+
if ActiveRecord::Base.connection.current_database != Rails.configuration.database_configuration['development']['database']
|
19
|
+
ActiveRecord::Base.establish_connection(:development)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
result = yield # this returns consumer handler message
|
24
|
+
|
25
|
+
result
|
26
|
+
rescue StandardError => e
|
27
|
+
log.error e
|
28
|
+
raise e
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'istox/helpers/logger'
|
2
|
+
|
3
|
+
module Istox
|
4
|
+
module IntegrationTest
|
5
|
+
class RabbitmqPublisherInterceptor
|
6
|
+
def call(message, _options)
|
7
|
+
message[:istox_integration_test] = '1'
|
8
|
+
rescue StandardError => e
|
9
|
+
log.error e
|
10
|
+
raise e
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/istox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: istox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.158.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -511,6 +511,11 @@ files:
|
|
511
511
|
- lib/istox/helpers/graphql_client.rb
|
512
512
|
- lib/istox/helpers/grpc_client.rb
|
513
513
|
- lib/istox/helpers/gruf_listener_hook.rb
|
514
|
+
- lib/istox/helpers/integration_test/grpc_client_interceptor.rb
|
515
|
+
- lib/istox/helpers/integration_test/grpc_server_interceptor.rb
|
516
|
+
- lib/istox/helpers/integration_test/rabbitmq_consumer_interceptor.rb
|
517
|
+
- lib/istox/helpers/integration_test/rabbitmq_publisher_interceptor.rb
|
518
|
+
- lib/istox/helpers/integration_test/settings.rb
|
514
519
|
- lib/istox/helpers/logger.rb
|
515
520
|
- lib/istox/helpers/messaging.rb
|
516
521
|
- lib/istox/helpers/my_open_struct.rb
|