istox 0.1.150 → 0.1.150.1

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.
data/.idea/workspace.xml CHANGED
@@ -4,10 +4,10 @@
4
4
  <list default="true" id="f70e0449-76c0-44d8-bcb9-7991f2a7e0f8" name="Default Changelist" comment="">
5
5
  <change beforePath="$PROJECT_DIR$/.idea/istox-gem.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/istox-gem.iml" afterDir="false" />
6
6
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7
- <change beforePath="$PROJECT_DIR$/lib/istox.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox.rb" afterDir="false" />
8
- <change beforePath="$PROJECT_DIR$/lib/istox/helpers/bunny_boot.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox/helpers/bunny_boot.rb" afterDir="false" />
9
- <change beforePath="$PROJECT_DIR$/lib/istox/helpers/dlm.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox/helpers/dlm.rb" afterDir="false" />
10
- <change beforePath="$PROJECT_DIR$/lib/istox/version.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox/version.rb" afterDir="false" />
7
+ <change beforePath="$PROJECT_DIR$/Gemfile.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Gemfile.lock" afterDir="false" />
8
+ <change beforePath="$PROJECT_DIR$/lib/istox/helpers/publisher.rb" beforeDir="false" afterPath="$PROJECT_DIR$/lib/istox/helpers/publisher.rb" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/spec/helpers/istox/publisher_spec.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/helpers/istox/publisher_spec.rb" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/spec/spec_helper.rb" beforeDir="false" afterPath="$PROJECT_DIR$/spec/spec_helper.rb" afterDir="false" />
11
11
  </list>
12
12
  <option name="SHOW_DIALOG" value="false" />
13
13
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -43,7 +43,11 @@
43
43
  <updated>1566200631090</updated>
44
44
  <workItem from="1566200632743" duration="997000" />
45
45
  <workItem from="1588041821198" duration="7000" />
46
- <workItem from="1588041848702" duration="662000" />
46
+ <workItem from="1588041848702" duration="4629000" />
47
+ <workItem from="1588230991821" duration="301000" />
48
+ <workItem from="1588595833261" duration="1768000" />
49
+ <workItem from="1589424486664" duration="887000" />
50
+ <workItem from="1589685965376" duration="22817000" />
47
51
  </task>
48
52
  <servers />
49
53
  </component>
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- istox (0.1.150)
4
+ istox (0.1.150.1)
5
5
  awesome_print
6
6
  binding_of_caller
7
7
  bunny (>= 2.12.0)
@@ -54,6 +54,37 @@ module Istox
54
54
  end
55
55
 
56
56
  @connection = ::Istox::BunnyBoot.connection
57
+
58
+ # Start a thread to sweep @channel
59
+ Thread.new do
60
+ loop do
61
+ Thread.new do
62
+ sleep 60 * 5
63
+
64
+ tid = []
65
+ Thread.list.each do |t|
66
+ tid << t.object_id
67
+ end
68
+ # log.info("Current tid is #{tid}")
69
+
70
+ tid_c = @channel.keys
71
+ # log.info("@channel tid is #{tid_c}")
72
+
73
+ tid_c.each do |t|
74
+ unless tid.include? t
75
+ # Close channel and remove it from @channel
76
+ log.debug("Thread #{t} doesn't exist any more, close channel for it and remove it from @channel")
77
+ @channel[t]['confirm-0'].close
78
+ @channel[t]['confirm-1'].close
79
+ @channel[t]['noconfirm'].close
80
+ @channel.delete t
81
+ end
82
+ end
83
+ end.join
84
+ end
85
+ end
86
+
87
+ @connection
57
88
  end
58
89
  end
59
90
 
@@ -77,39 +108,6 @@ module Istox
77
108
  @channel[Thread.current.object_id]['confirm-1'] = ::Istox::BunnyBoot.channel(connection, confirm: true)
78
109
  @channel[Thread.current.object_id]['noconfirm'] = ::Istox::BunnyBoot.channel(connection, confirm: false)
79
110
 
80
- threadId = Thread.current.object_id
81
- # Start new thread on receiving ACK from 'confirm-1' channel on the specified thread
82
- Thread.new do
83
- loop do
84
- sleep 5
85
-
86
- begin
87
- success = @channel[threadId]['confirm-1'].wait_for_confirms
88
- if success
89
- ::Istox::BunnyBoot.del_tracker_on_channel @channel[threadId]['confirm-1'].id
90
- else
91
- @channel[threadId]['confirm-1'].nacked_set.each do |n|
92
- log.debug("Publish Error[Async #{threadId}]: UNACK delivery tag is #{n}, republish message")
93
- eid = ::Istox::BunnyBoot.find_tracker_on_channel @channel[threadId]['confirm-1'].id, n, 'eid'
94
- payload = ::Istox::BunnyBoot.find_tracker_on_channel @channel[threadId]['confirm-1'].id, n, 'payload'
95
- payload = JSON.parse(payload, :symbolize_names => true) unless payload.nil?
96
- options = ::Istox::BunnyBoot.find_tracker_on_channel @channel[threadId]['confirm-1'].id, n, 'options'
97
- options = JSON.parse(options, :symbolize_names => true) unless options.nil?
98
- if options.nil?
99
- routing_key = nil
100
- else
101
- routing_key = options.delete :routing_key
102
- options[:delivery_tag] = n
103
- end
104
- publish(exchange: eid, routing_key: routing_key, message: payload, options: options)
105
- end
106
- end
107
- rescue => e
108
- # log.debug "wait_for_confirm error happening: #{e}"
109
- end
110
- end
111
- end
112
-
113
111
  @channel[Thread.current.object_id]
114
112
  end
115
113
 
@@ -132,7 +130,8 @@ module Istox
132
130
 
133
131
  def channel_from_mode(mode)
134
132
  if mode == 0 || mode == 1
135
- channel["confirm-#{mode.to_s}"]
133
+ # Currently we use mode 0 only
134
+ channel["confirm-0"]
136
135
  else
137
136
  channel['noconfirm']
138
137
  end
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.150'.freeze
2
+ VERSION = '0.1.150.1'.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.150
4
+ version: 0.1.150.1
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-04-28 00:00:00.000000000 Z
11
+ date: 2020-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print