istox 0.1.90 → 0.1.91

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: 76b135382a878056bd557369e7e9e402786e7c7ebb7ede4ba72da3eb9ae1ad48
4
- data.tar.gz: 6ad41087a7a7de2ea965019c9e2a453d36fb7abe749a2c9f8227d3bec3dcd301
3
+ metadata.gz: 953e7048e61191271768cd7520e88ddaac59ce5acca87e20f120d6b29803816d
4
+ data.tar.gz: a8af789c79d79ce1145f2403a7c55267060ebcc14ea80f40beb839fc5c119506
5
5
  SHA512:
6
- metadata.gz: 2e8270a43e58ddc2053f7d6eb7260571975144d86e10db7fd61a768ed7c032f3cf852c1aa6ade1d4b7534e9926df910c4b5737d84569631bf2fd654ef09338b7
7
- data.tar.gz: '078e26586b8c9ce0e56f77ee90f9c91eb12d592e76e522ec0f27c4d2e0e2c5cdaa6d06452dd34b54055ebdd11b96c8c0085b7304139862b220f703115e8faa19'
6
+ metadata.gz: 74ba49c25deedb38307c09a80415dacd01daae236d6cd121230bee3e185f2047d7230d2a17b196ec0f3441512ba2c04b876485c0469c743a40991944cc176523
7
+ data.tar.gz: 6638dde7e5b00304795605a7734446acabfe6c94c6862c2211e5caf64531eeca2ffdbaf12ac1a913974c0a973b84633df76fdf014e0ab8982d3730a14b6a3128
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.89)
4
+ istox (0.1.91)
5
5
  binding_of_caller
6
6
  bunny (>= 2.12.0)
7
7
  graphlient
@@ -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.error "Unable to publish to frontend for receipt #{receipt.inspect},
71
+ Rails.logger.warning "Unable to publish to frontend for receipt #{receipt.inspect},
72
72
  but will silently ignore the error"
73
- Rails.logger.error e
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.error "Unable to update resource_handled for receipt #{receipt.inspect},
79
+ Rails.logger.warning "Unable to update resource_handled for receipt #{receipt.inspect},
80
80
  but will silently ignore the error"
81
- Rails.logger.error e
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("::" + "#{data[0]}_consumer".camelize)
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
- if !config.manual_ack.nil?
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
- begin
44
- Rails.logger.info("Processing in consumer: #{klass}")
45
- klass.new.process(
46
- Hashie::Mash.new(JSON.parse(payload)),
47
- metadata,
48
- delivery_info
49
- )
50
- $channel.ack(delivery_info.delivery_tag) if manual_ack
51
- rescue Exception => e
52
- Rails.logger.error(e)
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.info "Querying Graphql host: #{host_type}, query: #{query}, variables: #{variables.inspect}"
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.info "Graphql result: #{return_values.inspect}"
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.info "Calling method in grpc method: #{method.inspect}, params: #{keyword_args.inspect}"
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.info "Time taken for grpc execution: #{Time.now - t1} seconds"
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.info "Result: #{return_values}"
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.info 'Reinitiating to grpc host at ' + host_url
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.info "Time taken for reinitiating grpc host: #{Time.now - t1} seconds"
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.info 'Before publish retrieve data..'
9
+ Rails.logger.debug 'Before publish retrieve data..'
11
10
  durable = data.fetch('publish')[exchange]['durable']
12
- Rails.logger.info "Publishing message: #{message} with exchange: #{exchange} routing key: #{routing_key}"
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.info 'Before publish retrieve data..'
20
+ Rails.logger.debug 'Before publish retrieve data..'
22
21
  durable = data.fetch('publish')[exchange]['durable']
23
22
  enqueue do
24
23
  $channel
@@ -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
- return read_data(totp_code_key(sid)).data[:code]
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
- return ::Istox::Vault::TOTP.validate?(sid, otp)
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("chainhub", query, { hashes: txhashes }).data.block_transactions
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
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.90'.freeze
2
+ VERSION = '0.1.91'.freeze
3
3
  end
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.90
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-01 00:00:00.000000000 Z
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