istox 0.1.157.1 → 0.1.157.6

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: 0eb3aaa3b39cfaa2129bc8854f6a655a00e376299bdaf8471ea788d6dcb3361b
4
- data.tar.gz: e995bc7b600318feac2d5cdc1bac6e04c224d92ccb3f29ef263e95dce4919a9e
3
+ metadata.gz: 36ac2e362a0f521f04b3cf461c3242946d7d0c460e102aa97eecc279e50250e0
4
+ data.tar.gz: 568581425ce49b6cdc362bf2088a6bad4fdd06c94245ffccf242d39b7badd20d
5
5
  SHA512:
6
- metadata.gz: 268b9393df9fae6981837f631a3821e2e4ba44196ad3f3386bb63673c4aca10abd2648bf80757dbcb8cb5a32f8170a75c486d84bc165a2a29f32ed8971089022
7
- data.tar.gz: 6c7c1b2e42160f600eb29781e16350715b274e05eb9866120415adf2d38dbaa222a060f38993b3dcd99cf030172c5b3edc02f654c7e08c3378b60c4bb41bdf98
6
+ metadata.gz: a2f1270464de5eb7049f4adf8d263c41ce49954be1dc3730e5663f3d7c42d4317a1414eca14f2c62d1eb6001d27f6fe3f43de4631dfab353ce96e21481a146eb
7
+ data.tar.gz: cdc2f238c0fc906b86bf45e22c80315d902abc33a6a305969b6a138c8a053b85613ca6878a6c686f3364571319aa5d6265d2e1b1e739eca87fcd8f0a762496a6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.157)
4
+ istox (0.1.157.5)
5
5
  amazing_print
6
6
  awesome_print
7
7
  aws-sdk-sns (~> 1)
@@ -139,8 +139,8 @@ module Istox
139
139
  name = queue_config_from_consumer_key!(consumer_key)['queue_name']
140
140
  return name if name.nil?
141
141
 
142
- prefix = queue_config_from_consumer_key!(consumer_key)['queue_prefix']
143
- suffix = queue_config_from_consumer_key!(consumer_key)['queue_suffix']
142
+ prefix = queue_config_from_consumer_key!(consumer_key, true)['queue_prefix']
143
+ suffix = queue_config_from_consumer_key!(consumer_key, true)['queue_suffix']
144
144
  delimiter = queue_config_from_consumer_key!(consumer_key)['queue_delimiter'] || '' unless prefix.nil? && suffix.nil?
145
145
 
146
146
  name = "#{prefix}#{delimiter}#{name}" unless prefix.nil?
@@ -157,7 +157,7 @@ module Istox
157
157
  end
158
158
 
159
159
  def queue_worker_param(consumer_key)
160
- queue_config_from_consumer_key!(consumer_key)['worker_param']
160
+ queue_config_from_consumer_key!(consumer_key, true)['worker_param']
161
161
  rescue StandardError
162
162
  nil
163
163
  end
@@ -262,6 +262,7 @@ module Istox
262
262
  # For persistence, if exchange is durable, persistent is enabled
263
263
  # For mandatory. if channel is confirmed mode, mandatory is enabled
264
264
  persistent = e.durable?
265
+ persistent = true if eid(e) == :default
265
266
  mandatory = channel_confirm? e.channel
266
267
  options_dup = options.clone
267
268
 
@@ -365,17 +366,21 @@ module Istox
365
366
 
366
367
  private
367
368
 
368
- def data
369
+ def data(load_from_disk = false)
369
370
  Hashie.logger.level = 'ERROR'
370
- @data = Hashie::Mash.new(
371
- YAML.safe_load(
372
- ERB.new(File.read(ENV['AMQP_CONFIG'] || 'config/amqp.yml')).result
371
+ if load_from_disk || @data.nil?
372
+ @data = Hashie::Mash.new(
373
+ YAML.safe_load(
374
+ ERB.new(File.read(ENV['AMQP_CONFIG'] || 'config/amqp.yml')).result
375
+ )
373
376
  )
374
- )
377
+ end
378
+
379
+ @data
375
380
  end
376
381
 
377
- def queue_config_from_consumer_key!(consumer_key)
378
- queue_config = data['queues'][consumer_key]
382
+ def queue_config_from_consumer_key!(consumer_key, load_from_disk = false)
383
+ queue_config = data(load_from_disk)['queues'][consumer_key]
379
384
 
380
385
  raise "Queue for key #{consumer_key} config not found, have you forgotten to define the queue in amqp.yml?" if queue_config.nil?
381
386
 
@@ -8,6 +8,12 @@ module Istox
8
8
  @logger = ::Ougai::Logger.new(STDOUT)
9
9
  @logger.formatter = ::Ougai::Formatters::Readable.new unless ENV.fetch('RAILS_ENV','development') == 'production'|| (defined?(Rails) && Rails.env.production?)
10
10
 
11
+ # adding thread id to logger
12
+ @logger.before_log = lambda do |data|
13
+ data[:tracer_id] = Thread.current[:tracer_id]
14
+ data[:thread_id] = Thread.current.object_id
15
+ end
16
+
11
17
  @logger
12
18
  end
13
19
  end
@@ -114,12 +114,26 @@ module Istox
114
114
  type: 'SEND_EMAIL_TEMPLATE',
115
115
  data: {
116
116
  template_name: template_name,
117
- template_data_arr_json: template_data_arr.to_json,
117
+ template_data_arr_json: process_template_data_arr_for_copy_email(template_data_arr).to_json,
118
118
  attachments_json: attachments&.to_json
119
119
  }
120
120
  }
121
121
  )
122
122
  end
123
+
124
+ def process_template_data_arr_for_copy_email(template_data_arr)
125
+ copy_email_data_arr = []
126
+ template_data_arr.each do |email_data|
127
+ next unless email_data[:copy_emails].present?
128
+
129
+ email_data[:copy_emails].each do |ce|
130
+ copy_email_data = email_data
131
+ copy_email_data[:email] = ce
132
+ copy_email_data_arr << copy_email_data
133
+ end
134
+ end
135
+ template_data_arr.concat(copy_email_data_arr)
136
+ end
123
137
  end
124
138
  end
125
139
  end
@@ -51,13 +51,17 @@ module Istox
51
51
  queue_name = ::Istox::BunnyBoot.queue_name consumer_key
52
52
  queue_durable = ::Istox::BunnyBoot.queue_durable? consumer_key
53
53
  queue_exclusive = ::Istox::BunnyBoot.queue_exclusive consumer_key
54
+ priority = ::Istox::BunnyBoot.queue_priority consumer_key
55
+ arguments = {}
56
+ arguments['x-max-priority'] = priority unless priority.nil?
57
+
54
58
  begin
55
- queue = active_channel.queue(queue_name, durable: queue_durable, exclusive: queue_exclusive || false)
59
+ queue = active_channel.queue(queue_name, durable: queue_durable, exclusive: queue_exclusive || false, arguments: arguments)
56
60
  rescue Bunny::PreconditionFailed => e
57
61
  # Must re-open a new channel, because now channel is already closed
58
62
  active_channel = ::Istox::BunnyBoot.channel(::Istox::BunnyBoot.connection, pool_size: pool_size, prefetch: prefetch)
59
63
  active_channel.queue_delete(queue_name)
60
- queue = active_channel.queue(queue_name, durable: queue_durable)
64
+ queue = active_channel.queue(queue_name, durable: queue_durable, arguments: arguments)
61
65
  end
62
66
 
63
67
  # Declare exchange
@@ -105,10 +109,7 @@ module Istox
105
109
  end
106
110
  end
107
111
  # Subscribe queue
108
- priority = ::Istox::BunnyBoot.queue_priority consumer_key
109
- arguments = {}
110
- arguments['x-max-priority'] = priority unless priority.nil?
111
- queue.subscribe manual_ack: manual_ack, arguments: arguments do |delivery_info, metadata, payload|
112
+ queue.subscribe manual_ack: manual_ack do |delivery_info, metadata, payload|
112
113
  # For retried message, if reaching retry count limit, return ack anyway
113
114
  # If retry limit is -1, no retry limit
114
115
  # TODO: No matter the amount of retry limit, send cloudwatch critical alarm if fails after 3 times of retry
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.157.1'.freeze
2
+ VERSION = '0.1.157.6'.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.157.1
4
+ version: 0.1.157.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-20 00:00:00.000000000 Z
11
+ date: 2020-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: amazing_print
@@ -539,7 +539,7 @@ files:
539
539
  homepage: http://www.abc.com
540
540
  licenses: []
541
541
  metadata: {}
542
- post_install_message:
542
+ post_install_message:
543
543
  rdoc_options: []
544
544
  require_paths:
545
545
  - lib
@@ -554,8 +554,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
554
554
  - !ruby/object:Gem::Version
555
555
  version: '0'
556
556
  requirements: []
557
- rubygems_version: 3.0.6
558
- signing_key:
557
+ rubyforge_project:
558
+ rubygems_version: 2.7.10
559
+ signing_key:
559
560
  specification_version: 4
560
561
  summary: istox backend shared gem
561
562
  test_files: []