istox 0.1.158.2 → 0.2.0
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/lib/istox.rb +0 -6
- data/lib/istox/helpers/common_helper.rb +6 -0
- data/lib/istox/helpers/formatter.rb +12 -2
- data/lib/istox/helpers/sns_publisher.rb +10 -3
- data/lib/istox/helpers/xray/grpc_client_xray_interceptor.rb +1 -0
- data/lib/istox/helpers/xray/grpc_server_xray_interceptor.rb +1 -0
- data/lib/istox/helpers/xray/rabbitmq_consumer_interceptor.rb +1 -0
- data/lib/istox/helpers/xray/rabbitmq_publisher_interceptor.rb +1 -0
- data/lib/istox/version.rb +1 -1
- metadata +2 -15
- data/.idea/.rakeTasks +0 -7
- data/.idea/encodings.xml +0 -4
- data/.idea/inspectionProfiles/Project_Default.xml +0 -6
- data/.idea/istox-gem.iml +0 -12
- data/.idea/misc.xml +0 -7
- data/.idea/modules.xml +0 -8
- data/.idea/vcs.xml +0 -6
- data/lib/istox/helpers/integration_test/grpc_client_interceptor.rb +0 -22
- data/lib/istox/helpers/integration_test/grpc_server_interceptor.rb +0 -31
- data/lib/istox/helpers/integration_test/rabbitmq_consumer_interceptor.rb +0 -32
- data/lib/istox/helpers/integration_test/rabbitmq_publisher_interceptor.rb +0 -14
- data/lib/istox/helpers/integration_test/settings.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32b60e5cea8c89edc2c9d9a9b4a9aaefeb026351d68ed6898b578f04213f7e81
|
4
|
+
data.tar.gz: e969dc0c25653d64d0de4173bd59178e3f2da8b080fe7db9d34f7c56b67bb791
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88109a86cc415878a19a461ed56252c42562fd44a40861eebe04f5a65a57c4b59df823851a047e59db49f78a5873e63eb99a27cf91f2e4a1c56646660b5f3e67
|
7
|
+
data.tar.gz: 9106e4ba0fd8bc5a965fcee3d3e78f1c6cf89ab5f2dcb1c3cbd7762913d6c6382b73c0173985c5f358aca6c58e697bfb78574c7c2c1b88af1b8a2702e89b5aea
|
data/lib/istox.rb
CHANGED
@@ -45,12 +45,6 @@ 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
|
-
|
54
48
|
require 'istox/models/blockchain_receipt'
|
55
49
|
require 'istox/models/concerns/blockchain_receipt_query'
|
56
50
|
require 'istox/consumers/blockchain_status_handler'
|
@@ -17,8 +17,18 @@ module Istox
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# format a money, eg. 20000.134 > SGD 20,000.14, position can be :front or :behind, abs_num: whether to absolute the number
|
20
|
-
def money(input, round_mode: :half_up, precision:
|
21
|
-
|
20
|
+
def money(input, round_mode: :half_up, precision: nil, currency:, position: :front, abs_num: false, hide_currency: false)
|
21
|
+
# precision = ::Istox::CommonHelper.get_currency_decimal(currency, precision)
|
22
|
+
|
23
|
+
decimal_place = if precision.present?
|
24
|
+
precision
|
25
|
+
else
|
26
|
+
::Istox::CommonHelper.get_currency_decimal(currency)
|
27
|
+
end
|
28
|
+
|
29
|
+
result = number(input, round_mode: round_mode, precision: decimal_place, abs_num: abs_num)
|
30
|
+
|
31
|
+
return result if hide_currency
|
22
32
|
|
23
33
|
return currency + ' ' + result if position == :front
|
24
34
|
|
@@ -14,7 +14,7 @@ module Istox
|
|
14
14
|
|
15
15
|
message = JSON.generate(message) unless message.is_a? String
|
16
16
|
|
17
|
-
sns_client.publish(
|
17
|
+
sns_client.publish(topic_arn: topic_arn || ENV.fetch('SNS_CLIENT_TOPIC', ''), message: message)
|
18
18
|
|
19
19
|
log.info('Publish to SNS successfully.')
|
20
20
|
rescue StandardError => e
|
@@ -28,8 +28,15 @@ module Istox
|
|
28
28
|
def sns_client
|
29
29
|
return @sns_client if @sns_client.present?
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
access_key = ENV.fetch('AWS_STS_ACCESS_KEY_ID', nil)
|
32
|
+
|
33
|
+
if access_key.present?
|
34
|
+
credentials = Aws::Credentials.new(ENV.fetch('AWS_STS_ACCESS_KEY_ID', nil), ENV.fetch('AWS_STS_SECRET_ACCESS_KEY', nil))
|
35
|
+
Aws.config.update(region: ENV.fetch('AWS_REGION', 'ap-southeast-1'),
|
36
|
+
credentials: credentials)
|
37
|
+
else
|
38
|
+
Aws.config.update(region: ENV.fetch('AWS_REGION', 'ap-southeast-1'))
|
39
|
+
end
|
33
40
|
|
34
41
|
@sns_client = Aws::SNS::Client.new(region: ENV.fetch('AWS_REGION', 'ap-southeast-1'))
|
35
42
|
end
|
@@ -22,6 +22,7 @@ module Istox
|
|
22
22
|
|
23
23
|
request_context.metadata[:xray_trace_id] = XRay.recorder.current_segment.trace_id
|
24
24
|
request_context.metadata[:xray_parent_id] = XRay.recorder.current_segment.id
|
25
|
+
Thread.current[:tracer_id] = XRay.recorder.current_segment.trace_id
|
25
26
|
|
26
27
|
result = yield
|
27
28
|
|
@@ -7,6 +7,7 @@ module Istox
|
|
7
7
|
meta = request.active_call.metadata
|
8
8
|
trace_id = (meta['xray_trace_id'] if meta.present? && meta.key?('xray_trace_id'))
|
9
9
|
parent_id = (meta['xray_parent_id'] if meta.present? && meta.key?('xray_parent_id'))
|
10
|
+
Thread.current[:tracer_id] = trace_id
|
10
11
|
|
11
12
|
XRay.recorder.begin_segment("#{::Istox::Xray::XrayInitializer.service_name}.grpc.#{request.method_key}",
|
12
13
|
trace_id: trace_id, parent_id: parent_id)
|
@@ -8,6 +8,7 @@ module Istox
|
|
8
8
|
|
9
9
|
trace_id = (payload_hash[:xray_trace_id] if payload_hash.key?(:xray_trace_id))
|
10
10
|
parent_id = (payload_hash[:xray_parent_id] if payload_hash.key?(:xray_parent_id))
|
11
|
+
Thread.current[:tracer_id] = trace_id
|
11
12
|
|
12
13
|
arr = [delivery_info[:exchange]&.downcase, delivery_info[:routing_key]&.downcase, payload_hash[:type]&.downcase].compact
|
13
14
|
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: amazing_print
|
@@ -480,14 +480,6 @@ extensions: []
|
|
480
480
|
extra_rdoc_files: []
|
481
481
|
files:
|
482
482
|
- ".gitignore"
|
483
|
-
- ".idea/.rakeTasks"
|
484
|
-
- ".idea/encodings.xml"
|
485
|
-
- ".idea/inspectionProfiles/Project_Default.xml"
|
486
|
-
- ".idea/istox-gem.iml"
|
487
|
-
- ".idea/misc.xml"
|
488
|
-
- ".idea/modules.xml"
|
489
|
-
- ".idea/vcs.xml"
|
490
|
-
- ".idea/workspace.xml"
|
491
483
|
- ".rubocop.yml"
|
492
484
|
- ".solargraph.yml"
|
493
485
|
- CODE_OF_CONDUCT.md
|
@@ -511,11 +503,6 @@ files:
|
|
511
503
|
- lib/istox/helpers/graphql_client.rb
|
512
504
|
- lib/istox/helpers/grpc_client.rb
|
513
505
|
- 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
|
519
506
|
- lib/istox/helpers/logger.rb
|
520
507
|
- lib/istox/helpers/messaging.rb
|
521
508
|
- lib/istox/helpers/my_open_struct.rb
|
data/.idea/.rakeTasks
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
-
You are allowed to:
|
4
|
-
1. Remove rake task
|
5
|
-
2. Add existing rake tasks
|
6
|
-
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
-
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.idea/encodings.xml
DELETED
data/.idea/istox-gem.iml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="ModuleRunConfigurationManager">
|
4
|
-
<shared />
|
5
|
-
</component>
|
6
|
-
<component name="NewModuleRootManager">
|
7
|
-
<content url="file://$MODULE_DIR$" />
|
8
|
-
<orderEntry type="inheritedJdk" />
|
9
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
10
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.16.6, RVM: ruby-2.5.3 [global]) [gem]" level="application" />
|
11
|
-
</component>
|
12
|
-
</module>
|
data/.idea/misc.xml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="JavaScriptSettings">
|
4
|
-
<option name="languageLevel" value="ES6" />
|
5
|
-
</component>
|
6
|
-
<component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.5.3 [global]" project-jdk-type="RUBY_SDK" />
|
7
|
-
</project>
|
data/.idea/modules.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<project version="4">
|
3
|
-
<component name="ProjectModuleManager">
|
4
|
-
<modules>
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/istox-gem.iml" filepath="$PROJECT_DIR$/.idea/istox-gem.iml" />
|
6
|
-
</modules>
|
7
|
-
</component>
|
8
|
-
</project>
|
data/.idea/vcs.xml
DELETED
@@ -1,22 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,14 +0,0 @@
|
|
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
|