istox 0.1.90 → 0.1.91
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 +1 -1
- data/lib/istox.rb +0 -2
- data/lib/istox/consumers/blockchain_status_handler.rb +4 -4
- data/lib/istox/helpers/bunny_boot.rb +14 -19
- data/lib/istox/helpers/graphql_client.rb +2 -2
- data/lib/istox/helpers/grpc_client.rb +5 -5
- data/lib/istox/helpers/publisher.rb +3 -4
- data/lib/istox/helpers/vault.rb +3 -5
- data/lib/istox/interfaces/chainhub/transaction.rb +3 -3
- data/lib/istox/version.rb +1 -1
- metadata +2 -4
- data/lib/istox/logging/hash_logging.rb +0 -26
- data/lib/istox/logging/log_formatter.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 953e7048e61191271768cd7520e88ddaac59ce5acca87e20f120d6b29803816d
|
4
|
+
data.tar.gz: a8af789c79d79ce1145f2403a7c55267060ebcc14ea80f40beb839fc5c119506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74ba49c25deedb38307c09a80415dacd01daae236d6cd121230bee3e185f2047d7230d2a17b196ec0f3441512ba2c04b876485c0469c743a40991944cc176523
|
7
|
+
data.tar.gz: 6638dde7e5b00304795605a7734446acabfe6c94c6862c2211e5caf64531eeca2ffdbaf12ac1a913974c0a973b84633df76fdf014e0ab8982d3730a14b6a3128
|
data/Gemfile.lock
CHANGED
data/lib/istox.rb
CHANGED
@@ -29,7 +29,5 @@ module Istox
|
|
29
29
|
require 'istox/models/blockchain_receipt'
|
30
30
|
require 'istox/models/concerns/blockchain_receipt_query'
|
31
31
|
require 'istox/consumers/blockchain_status_handler'
|
32
|
-
require 'istox/logging/hash_logging'
|
33
|
-
require 'istox/logging/log_formatter'
|
34
32
|
require 'istox/quant/bond'
|
35
33
|
end
|
@@ -68,17 +68,17 @@ module Istox
|
|
68
68
|
}
|
69
69
|
)
|
70
70
|
rescue StandardError => e
|
71
|
-
Rails.logger.
|
71
|
+
Rails.logger.warning "Unable to publish to frontend for receipt #{receipt.inspect},
|
72
72
|
but will silently ignore the error"
|
73
|
-
Rails.logger.
|
73
|
+
Rails.logger.warning e
|
74
74
|
end
|
75
75
|
|
76
76
|
def mark_resource_handled(receipt)
|
77
77
|
receipt.update(resource_handled: true)
|
78
78
|
rescue StandardError => e
|
79
|
-
Rails.logger.
|
79
|
+
Rails.logger.warning "Unable to update resource_handled for receipt #{receipt.inspect},
|
80
80
|
but will silently ignore the error"
|
81
|
-
Rails.logger.
|
81
|
+
Rails.logger.warning e
|
82
82
|
end
|
83
83
|
|
84
84
|
def resource_handled?(receipt)
|
@@ -2,7 +2,6 @@ require 'bunny'
|
|
2
2
|
module Istox
|
3
3
|
class BunnyBoot
|
4
4
|
class << self
|
5
|
-
|
6
5
|
def initialize!(amqp_config_path)
|
7
6
|
@@amqp_config_path = amqp_config_path
|
8
7
|
::Istox::Publisher.initialize!(amqp_config_path)
|
@@ -21,7 +20,7 @@ module Istox
|
|
21
20
|
def subscribe_to_queues
|
22
21
|
data.queues.each do |data|
|
23
22
|
config = OpenStruct.new(data[1])
|
24
|
-
klass = Object.const_get(
|
23
|
+
klass = Object.const_get('::' + "#{data[0]}_consumer".camelize)
|
25
24
|
exchange_type = if config.exchange.ends_with?('.fanout')
|
26
25
|
:fanout
|
27
26
|
else
|
@@ -33,25 +32,21 @@ module Istox
|
|
33
32
|
config.name,
|
34
33
|
durable: config.durable
|
35
34
|
).bind(exchange(config.exchange, exchange_type), options)
|
36
|
-
|
35
|
+
|
37
36
|
manual_ack = true
|
38
|
-
|
39
|
-
manual_ack = config.manual_ack
|
40
|
-
end
|
37
|
+
manual_ack = config.manual_ack unless config.manual_ack.nil?
|
41
38
|
|
42
39
|
queue.subscribe manual_ack: manual_ack do |delivery_info, metadata, payload|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
$channel.nack(delivery_info.delivery_tag, false, true)
|
54
|
-
end
|
40
|
+
Rails.logger.debug("Processing in consumer: #{klass}")
|
41
|
+
klass.new.process(
|
42
|
+
Hashie::Mash.new(JSON.parse(payload)),
|
43
|
+
metadata,
|
44
|
+
delivery_info
|
45
|
+
)
|
46
|
+
$channel.ack(delivery_info.delivery_tag) if manual_ack
|
47
|
+
rescue StandardError => e
|
48
|
+
Rails.logger.error(e)
|
49
|
+
$channel.nack(delivery_info.delivery_tag, false, true)
|
55
50
|
end
|
56
51
|
end
|
57
52
|
end
|
@@ -76,4 +71,4 @@ module Istox
|
|
76
71
|
end
|
77
72
|
end
|
78
73
|
end
|
79
|
-
end
|
74
|
+
end
|
@@ -13,12 +13,12 @@ module Istox
|
|
13
13
|
|
14
14
|
raise "Please make sure you have initialised graphql cient for host #{host_type}" unless client
|
15
15
|
|
16
|
-
Rails.logger.
|
16
|
+
Rails.logger.debug "Querying Graphql host: #{host_type}, query: #{query}, variables: #{variables.inspect}"
|
17
17
|
result = client.query(query, variables)
|
18
18
|
|
19
19
|
return_values = ::Istox::CommonHelper.to_open_struct(result&.data)
|
20
20
|
|
21
|
-
Rails.logger.
|
21
|
+
Rails.logger.debug "Graphql result: #{return_values.inspect}"
|
22
22
|
|
23
23
|
return_values
|
24
24
|
end
|
@@ -18,14 +18,14 @@ module Istox
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def execute(host_type, service, method, **keyword_args)
|
21
|
-
Rails.logger.
|
21
|
+
Rails.logger.debug "Calling method in grpc method: #{method.inspect}, params: #{keyword_args.inspect}"
|
22
22
|
t1 = Time.now
|
23
23
|
|
24
24
|
result = get_host(host_type, service).call(method, keyword_args)
|
25
|
-
Rails.logger.
|
25
|
+
Rails.logger.debug "Time taken for grpc execution: #{Time.now - t1} seconds"
|
26
26
|
|
27
27
|
return_values = ::Istox::CommonHelper.to_open_struct(result.message)
|
28
|
-
Rails.logger.
|
28
|
+
Rails.logger.debug "Result: #{return_values}"
|
29
29
|
|
30
30
|
return_values
|
31
31
|
end
|
@@ -49,10 +49,10 @@ module Istox
|
|
49
49
|
host_url = @@hosts[host_type]
|
50
50
|
raise StandardError, 'Unable to find host, have you forgotten to add host to grpc client?' unless host_url
|
51
51
|
|
52
|
-
Rails.logger.
|
52
|
+
Rails.logger.debug 'Reinitiating to grpc host at ' + host_url
|
53
53
|
t1 = Time.now
|
54
54
|
@@services[get_key(host_type, service)] = ::Gruf::Client.new(service: service, options: { hostname: host_url })
|
55
|
-
Rails.logger.
|
55
|
+
Rails.logger.debug "Time taken for reinitiating grpc host: #{Time.now - t1} seconds"
|
56
56
|
end
|
57
57
|
|
58
58
|
def get_key(host_type, service)
|
@@ -1,15 +1,14 @@
|
|
1
1
|
module Istox
|
2
2
|
class Publisher
|
3
3
|
class << self
|
4
|
-
|
5
4
|
def initialize!(amqp_config_path)
|
6
5
|
@@amqp_config_path = amqp_config_path
|
7
6
|
end
|
8
7
|
|
9
8
|
def publish(exchange, routing_key, message)
|
10
|
-
Rails.logger.
|
9
|
+
Rails.logger.debug 'Before publish retrieve data..'
|
11
10
|
durable = data.fetch('publish')[exchange]['durable']
|
12
|
-
Rails.logger.
|
11
|
+
Rails.logger.debug "Publishing message: #{message} with exchange: #{exchange} routing key: #{routing_key}"
|
13
12
|
enqueue do
|
14
13
|
$channel
|
15
14
|
.direct(exchange, durable: durable)
|
@@ -18,7 +17,7 @@ module Istox
|
|
18
17
|
end
|
19
18
|
|
20
19
|
def publish_to_fanout(exchange, message)
|
21
|
-
Rails.logger.
|
20
|
+
Rails.logger.debug 'Before publish retrieve data..'
|
22
21
|
durable = data.fetch('publish')[exchange]['durable']
|
23
22
|
enqueue do
|
24
23
|
$channel
|
data/lib/istox/helpers/vault.rb
CHANGED
@@ -4,7 +4,6 @@ module Istox
|
|
4
4
|
module Vault
|
5
5
|
module TOTP
|
6
6
|
class << self
|
7
|
-
|
8
7
|
def create(sid, host)
|
9
8
|
Rails.logger.debug { "Generate vault TOTP for key #{totp_key(sid).inspect}" }
|
10
9
|
|
@@ -18,7 +17,7 @@ module Istox
|
|
18
17
|
|
19
18
|
def generate_code(sid)
|
20
19
|
Rails.logger.debug { "Generate 6-digit OTP code: key #{totp_code_key(sid)}" }
|
21
|
-
|
20
|
+
read_data(totp_code_key(sid)).data[:code]
|
22
21
|
end
|
23
22
|
|
24
23
|
def validate?(sid, code)
|
@@ -54,7 +53,6 @@ module Istox
|
|
54
53
|
end
|
55
54
|
|
56
55
|
class << self
|
57
|
-
|
58
56
|
def logical
|
59
57
|
::Vault.logical
|
60
58
|
end
|
@@ -80,8 +78,8 @@ module Istox
|
|
80
78
|
end
|
81
79
|
|
82
80
|
def validate_otp(sid, otp)
|
83
|
-
|
84
|
-
rescue => e
|
81
|
+
::Istox::Vault::TOTP.validate?(sid, otp)
|
82
|
+
rescue StandardError => e
|
85
83
|
raise e
|
86
84
|
false
|
87
85
|
end
|
@@ -12,9 +12,9 @@ module Istox
|
|
12
12
|
}
|
13
13
|
}
|
14
14
|
GRAPHQL
|
15
|
-
|
16
|
-
::Istox::GraphqlClient.query(
|
17
|
-
end
|
15
|
+
|
16
|
+
::Istox::GraphqlClient.query('chainhub', query, hashes: txhashes).data.block_transactions
|
17
|
+
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
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.91
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siong Leng
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -304,8 +304,6 @@ files:
|
|
304
304
|
- lib/istox/helpers/publisher.rb
|
305
305
|
- lib/istox/helpers/vault.rb
|
306
306
|
- lib/istox/interfaces/chainhub/transaction.rb
|
307
|
-
- lib/istox/logging/hash_logging.rb
|
308
|
-
- lib/istox/logging/log_formatter.rb
|
309
307
|
- lib/istox/models/blockchain_receipt.rb
|
310
308
|
- lib/istox/models/concerns/blockchain_receipt_query.rb
|
311
309
|
- lib/istox/quant/bond.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Istox
|
2
|
-
module Logging
|
3
|
-
module HashLogging
|
4
|
-
include ActiveSupport::TaggedLogging
|
5
|
-
|
6
|
-
def self.new(logger)
|
7
|
-
logger.formatter ||= ActiveSupport::Logger::SimpleFormatter.new
|
8
|
-
logger.formatter.extend Formatter
|
9
|
-
logger.extend(self)
|
10
|
-
end
|
11
|
-
|
12
|
-
module Formatter
|
13
|
-
include ActiveSupport::TaggedLogging::Formatter
|
14
|
-
|
15
|
-
def call(severity, timestamp, progname, msg)
|
16
|
-
tagged_message = if msg.is_a?(Hash) then tags_text.present? ? msg.merge(tags: tags_text) : msg
|
17
|
-
elsif tags_text.present? then { message: msg, tag: tags_text }
|
18
|
-
else msg
|
19
|
-
end
|
20
|
-
|
21
|
-
self.class.instance_method(:call).bind(self).call(severity, timestamp, progname, tagged_message)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Istox
|
4
|
-
module Logging
|
5
|
-
class LogFormatter
|
6
|
-
def call(severity, _time, progname, msg = '')
|
7
|
-
return '' if msg.blank?
|
8
|
-
|
9
|
-
hash = {
|
10
|
-
level: severity,
|
11
|
-
message: processed_message(msg)
|
12
|
-
}
|
13
|
-
|
14
|
-
hash[:app] = progname if progname.present?
|
15
|
-
|
16
|
-
hash.to_json + "\n"
|
17
|
-
|
18
|
-
# return "timestamp='#{time}' level=#{severity} progname='#{progname}' #{processed_message(msg)}\n" if progname.present?
|
19
|
-
# "timestamp='#{time}' level=#{severity} #{processed_message(msg)}\n"
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def processed_message(msg)
|
25
|
-
return msg.map { |k, v| "#{k}='#{v&.strip}'" }.join(' ') if msg.is_a?(Hash)
|
26
|
-
|
27
|
-
msg
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|