isimud 1.3.1 → 1.3.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f4162cffed96ee6706c449f3f22920e71d4344c
4
- data.tar.gz: 62745767638aa63ed33ffdc78c64918f3834b75b
3
+ metadata.gz: c4bd12288bf7f6d9c776b2873356404985e009d5
4
+ data.tar.gz: e228c75de6ac2b514ac79769d092500acf13481b
5
5
  SHA512:
6
- metadata.gz: 85fbfd7875e94f1b999a061c5a9edf5d0c5396d0880bb8d17eedd13f93eaa5dc128aaa2525c70f7118cdceb8b520ee008efbbe010239404223e9a7dc44cabe8d
7
- data.tar.gz: 44642e7749e0865e1d1dbd5f5217fe5b293f465fa3199f2c508137b0f1798a2293c32a6fb07b4ca0c482a6f1c944f60f1a5de0e7e85eb7aabed6ae36809453a5
6
+ metadata.gz: 7b84a8cd3ad57e80fb9165cf16336d017e294f1244cb0d98bc278d9c209c116c590ce03e8e4c69b39f53ffe5ea4000e54e579e64626246a1a4497f0b6205300f
7
+ data.tar.gz: e5f2b25aa559d680d1e4521e246ed00a59328d4e3abe9a6fbfa32a437130b49f7761f5de3ed0208756425899565814e64279fee51e9a575720ecf910af84a2c0
@@ -2,14 +2,14 @@ lib/isimud.rb 5a9fee170ff924c6347d98fb5a80980d5f0ecc9a
2
2
  lib/isimud/event.rb f29a804bfa084e68329825b5fb9863d268f3ff27
3
3
  lib/isimud/tasks.rb 8d07d80e178928098e959ebdcbda1707e9b50617
4
4
  lib/isimud/client.rb 88ffac5ff4cc3306d0f1c9f9a1ca9d5c344e81cf
5
- lib/isimud/version.rb 10899b20ed9eabb999e6724cdc5297914abb3db8
5
+ lib/isimud/version.rb 3c726b1fa933bfa72e64a8c111f741f10a0a8220
6
6
  lib/isimud/logging.rb 2f506f049011441628a3d573d8e2a670156b4a3a
7
7
  lib/isimud/railtie.rb e644c4d74ae8298f11dd0c2fcae1d72259e24ea3
8
- lib/isimud/test_client.rb 5f5e0bdcb31289f4560248caad17d1b7bbc32201
8
+ lib/isimud/test_client.rb e70e3b96b7cec013f8edcb4005ea72ea8acc48c7
9
9
  lib/isimud/bunny_client.rb 7009922019087e2c9920073cb79c93aba8446dc4
10
10
  lib/isimud/model_watcher.rb f6694603386e538f755ff7217f975f04c9529c26
11
11
  lib/isimud/event_observer.rb 64c3af1d81df6a97cf9700eb71dc4d241f5b0044
12
- lib/isimud/event_listener.rb b15d795824b48e2890d3916403acdc6a73e6a106
12
+ lib/isimud/event_listener.rb e7fea6bb36d76bc50c28c32869653d0558a3e7f7
13
13
  lib/rails/generators/isimud/config_generator.rb d1c964f26c6e0f0289343bac17d3a9b1f99d7a98
14
14
  lib/rails/generators/isimud/initializer_generator.rb c7b188459d17d35ccbfa820a434dd6a97a58aeeb
15
15
  lib/rails/generators/isimud/templates/initializer.rb 6b937955296d704bfa4a06eec91ce14a6dd954ba
Binary file
Binary file
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isimud (1.3.1)
4
+ isimud (1.3.8)
5
5
  activerecord (>= 4.1.4)
6
6
  activesupport (>= 4.1.4)
7
7
  bunny (>= 1.6.0)
@@ -32,12 +32,12 @@ GEM
32
32
  minitest (~> 5.1)
33
33
  thread_safe (~> 0.1)
34
34
  tzinfo (~> 1.1)
35
- amq-protocol (2.0.0)
35
+ amq-protocol (2.0.1)
36
36
  arel (5.0.1.20140414130214)
37
37
  awesome_print (1.6.1)
38
38
  builder (3.2.2)
39
- bunny (2.2.0)
40
- amq-protocol (>= 2.0.0)
39
+ bunny (2.3.0)
40
+ amq-protocol (>= 2.0.1)
41
41
  chronic_duration (0.10.6)
42
42
  numerizer (~> 0.1.1)
43
43
  codeclimate-test-reporter (0.4.8)
@@ -110,4 +110,4 @@ DEPENDENCIES
110
110
  yard
111
111
 
112
112
  BUNDLED WITH
113
- 1.10.6
113
+ 1.11.2
data/README.md CHANGED
@@ -77,6 +77,34 @@ if they do not exist.
77
77
 
78
78
  ## Changes
79
79
 
80
+ ### 1.3.8
81
+
82
+ * In EventListener event thread, rescue all exceptions, not just Bunny ones.
83
+
84
+ ### 1.3.7
85
+
86
+ * Change instance var 'status' inside the start event thread
87
+
88
+ ### 1.3.6
89
+
90
+ * Don't include ModelWatcher attributes in event publish log message
91
+ * Include routing key in ModelWatcher event publish log message
92
+
93
+ ### 1.3.5
94
+
95
+ * Added option to EventObserver#observe_events to recreate bindings for observer queues
96
+ * EventListener only create bindings and queues for EventObserver instances on initial startup
97
+
98
+ ### 1.3.4
99
+
100
+ * Always recreate bindings for observer queues when EventListener starts the event thread.
101
+ * Cleaned up method signature on EventObserver#delete_queue so that a client may be passed to it.
102
+
103
+ ### 1.3.3
104
+
105
+ * Fixed handling of exceptions in TestClient
106
+ * Make EventListener#has_observer? public
107
+
80
108
  ### 1.3.1
81
109
 
82
110
  * Add EventObserver#deactivate_observer to trigger queue deletion for an observer instance.
@@ -125,7 +125,7 @@
125
125
  <dt id="VERSION-constant" class="">VERSION =
126
126
 
127
127
  </dt>
128
- <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.3.1</span><span class='tstring_end'>&#39;</span></span></pre></dd>
128
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>1.3.2</span><span class='tstring_end'>&#39;</span></span></pre></dd>
129
129
 
130
130
  </dl>
131
131
 
@@ -1691,7 +1691,7 @@ it</p>
1691
1691
  </div>
1692
1692
 
1693
1693
  <div id="footer">
1694
- Generated on Wed Jan 13 16:27:29 2016 by
1694
+ Generated on Mon Jan 18 17:07:52 2016 by
1695
1695
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1696
1696
  0.8.7.6 (ruby-2.2.3).
1697
1697
  </div>
@@ -1698,7 +1698,7 @@ be called.</code></pre>
1698
1698
  </div>
1699
1699
 
1700
1700
  <div id="footer">
1701
- Generated on Wed Jan 13 16:27:29 2016 by
1701
+ Generated on Mon Jan 18 17:07:52 2016 by
1702
1702
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1703
1703
  0.8.7.6 (ruby-2.2.3).
1704
1704
  </div>
@@ -1021,7 +1021,7 @@ for instance.</p>
1021
1021
  </div>
1022
1022
 
1023
1023
  <div id="footer">
1024
- Generated on Wed Jan 13 16:27:29 2016 by
1024
+ Generated on Mon Jan 18 17:07:52 2016 by
1025
1025
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1026
1026
  0.8.7.6 (ruby-2.2.3).
1027
1027
  </div>
@@ -1607,7 +1607,7 @@ based on the class and ID of the object.</p>
1607
1607
  </div>
1608
1608
 
1609
1609
  <div id="footer">
1610
- Generated on Wed Jan 13 16:27:29 2016 by
1610
+ Generated on Mon Jan 18 17:07:52 2016 by
1611
1611
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1612
1612
  0.8.7.6 (ruby-2.2.3).
1613
1613
  </div>
@@ -1226,7 +1226,7 @@ threads</p>
1226
1226
  </div>
1227
1227
 
1228
1228
  <div id="footer">
1229
- Generated on Wed Jan 13 16:27:29 2016 by
1229
+ Generated on Mon Jan 18 17:07:52 2016 by
1230
1230
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1231
1231
  0.8.7.6 (ruby-2.2.3).
1232
1232
  </div>
@@ -740,7 +740,7 @@ want to specify an alternative exchange.</p>
740
740
  </div>
741
741
 
742
742
  <div id="footer">
743
- Generated on Wed Jan 13 16:27:29 2016 by
743
+ Generated on Mon Jan 18 17:07:52 2016 by
744
744
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
745
745
  0.8.7.6 (ruby-2.2.3).
746
746
  </div>
@@ -283,7 +283,7 @@ class</p>
283
283
  </div>
284
284
 
285
285
  <div id="footer">
286
- Generated on Wed Jan 13 16:27:29 2016 by
286
+ Generated on Mon Jan 18 17:07:52 2016 by
287
287
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
288
288
  0.8.7.6 (ruby-2.2.3).
289
289
  </div>
@@ -108,7 +108,7 @@
108
108
  </div>
109
109
 
110
110
  <div id="footer">
111
- Generated on Wed Jan 13 16:27:29 2016 by
111
+ Generated on Mon Jan 18 17:07:52 2016 by
112
112
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
113
113
  0.8.7.6 (ruby-2.2.3).
114
114
  </div>
@@ -183,7 +183,7 @@
183
183
  </div>
184
184
 
185
185
  <div id="footer">
186
- Generated on Wed Jan 13 16:27:29 2016 by
186
+ Generated on Mon Jan 18 17:07:52 2016 by
187
187
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
188
188
  0.8.7.6 (ruby-2.2.3).
189
189
  </div>
@@ -183,7 +183,7 @@
183
183
  </div>
184
184
 
185
185
  <div id="footer">
186
- Generated on Wed Jan 13 16:27:29 2016 by
186
+ Generated on Mon Jan 18 17:07:52 2016 by
187
187
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
188
188
  0.8.7.6 (ruby-2.2.3).
189
189
  </div>
@@ -221,7 +221,7 @@
221
221
  </div>
222
222
 
223
223
  <div id="footer">
224
- Generated on Wed Jan 13 16:27:29 2016 by
224
+ Generated on Mon Jan 18 17:07:52 2016 by
225
225
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
226
226
  0.8.7.6 (ruby-2.2.3).
227
227
  </div>
@@ -303,7 +303,7 @@
303
303
  </div>
304
304
 
305
305
  <div id="footer">
306
- Generated on Wed Jan 13 16:27:29 2016 by
306
+ Generated on Mon Jan 18 17:07:52 2016 by
307
307
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
308
308
  0.8.7.6 (ruby-2.2.3).
309
309
  </div>
@@ -502,7 +502,7 @@ a return value may be included in the list of attributes.</p>
502
502
  </div>
503
503
 
504
504
  <div id="footer">
505
- Generated on Wed Jan 13 16:27:29 2016 by
505
+ Generated on Mon Jan 18 17:07:52 2016 by
506
506
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
507
507
  0.8.7.6 (ruby-2.2.3).
508
508
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Wed Jan 13 16:27:29 2016 by
117
+ Generated on Mon Jan 18 17:07:52 2016 by
118
118
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.8.7.6 (ruby-2.2.3).
120
120
  </div>
@@ -521,12 +521,12 @@ occur.</p>
521
521
  <pre class="lines">
522
522
 
523
523
 
524
- 63
525
524
  64
526
- 65</pre>
525
+ 65
526
+ 66</pre>
527
527
  </td>
528
528
  <td>
529
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 63</span>
529
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 64</span>
530
530
 
531
531
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_connection'>connection</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
532
532
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_queues'>queues</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
@@ -606,13 +606,13 @@ occur.</p>
606
606
  <pre class="lines">
607
607
 
608
608
 
609
- 86
610
609
  87
611
610
  88
612
- 89</pre>
611
+ 89
612
+ 90</pre>
613
613
  </td>
614
614
  <td>
615
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 86</span>
615
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 87</span>
616
616
 
617
617
  <span class='kw'>def</span> <span class='id identifier rubyid_bind'>bind</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='comma'>,</span> <span class='id identifier rubyid_exchange_name'>exchange_name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_keys'>keys</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
618
618
  <span class='id identifier rubyid_queue'>queue</span> <span class='op'>=</span> <span class='id identifier rubyid_create_queue'>create_queue</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='comma'>,</span> <span class='id identifier rubyid_exchange_name'>exchange_name</span><span class='comma'>,</span> <span class='label'>routing_keys:</span> <span class='id identifier rubyid_keys'>keys</span><span class='rparen'>)</span>
@@ -638,12 +638,12 @@ occur.</p>
638
638
  <pre class="lines">
639
639
 
640
640
 
641
- 71
642
641
  72
643
- 73</pre>
642
+ 73
643
+ 74</pre>
644
644
  </td>
645
645
  <td>
646
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 71</span>
646
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 72</span>
647
647
 
648
648
  <span class='kw'>def</span> <span class='id identifier rubyid_channel'>channel</span>
649
649
  <span class='kw'>self</span>
@@ -668,11 +668,11 @@ occur.</p>
668
668
  <pre class="lines">
669
669
 
670
670
 
671
- 79
672
- 80</pre>
671
+ 80
672
+ 81</pre>
673
673
  </td>
674
674
  <td>
675
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 79</span>
675
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 80</span>
676
676
 
677
677
  <span class='kw'>def</span> <span class='id identifier rubyid_close'>close</span>
678
678
  <span class='kw'>end</span></pre>
@@ -696,12 +696,12 @@ occur.</p>
696
696
  <pre class="lines">
697
697
 
698
698
 
699
- 67
700
699
  68
701
- 69</pre>
700
+ 69
701
+ 70</pre>
702
702
  </td>
703
703
  <td>
704
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 67</span>
704
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 68</span>
705
705
 
706
706
  <span class='kw'>def</span> <span class='id identifier rubyid_connect'>connect</span>
707
707
  <span class='kw'>self</span>
@@ -748,12 +748,12 @@ occur.</p>
748
748
  <pre class="lines">
749
749
 
750
750
 
751
- 75
752
751
  76
753
- 77</pre>
752
+ 77
753
+ 78</pre>
754
754
  </td>
755
755
  <td>
756
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 75</span>
756
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 76</span>
757
757
 
758
758
  <span class='kw'>def</span> <span class='id identifier rubyid_connected?'>connected?</span>
759
759
  <span class='kw'>true</span>
@@ -778,7 +778,6 @@ occur.</p>
778
778
  <pre class="lines">
779
779
 
780
780
 
781
- 95
782
781
  96
783
782
  97
784
783
  98
@@ -786,10 +785,11 @@ occur.</p>
786
785
  100
787
786
  101
788
787
  102
789
- 103</pre>
788
+ 103
789
+ 104</pre>
790
790
  </td>
791
791
  <td>
792
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 95</span>
792
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 96</span>
793
793
 
794
794
  <span class='kw'>def</span> <span class='id identifier rubyid_create_queue'>create_queue</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='comma'>,</span> <span class='id identifier rubyid_exchange_name'>exchange_name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
795
795
  <span class='id identifier rubyid_keys'>keys</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:routing_keys</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
@@ -820,12 +820,12 @@ occur.</p>
820
820
  <pre class="lines">
821
821
 
822
822
 
823
- 82
824
823
  83
825
- 84</pre>
824
+ 84
825
+ 85</pre>
826
826
  </td>
827
827
  <td>
828
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 82</span>
828
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 83</span>
829
829
 
830
830
  <span class='kw'>def</span> <span class='id identifier rubyid_delete_queue'>delete_queue</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='rparen'>)</span>
831
831
  <span class='id identifier rubyid_queues'>queues</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='rparen'>)</span>
@@ -850,15 +850,15 @@ occur.</p>
850
850
  <pre class="lines">
851
851
 
852
852
 
853
- 91
854
853
  92
855
- 93</pre>
854
+ 93
855
+ 94</pre>
856
856
  </td>
857
857
  <td>
858
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 91</span>
858
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 92</span>
859
859
 
860
860
  <span class='kw'>def</span> <span class='id identifier rubyid_find_queue'>find_queue</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
861
- <span class='id identifier rubyid_queues'>queues</span><span class='lbracket'>[</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'>Queue</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='rparen'>)</span>
861
+ <span class='id identifier rubyid_queues'>queues</span><span class='lbracket'>[</span><span class='id identifier rubyid_queue_name'>queue_name</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'>Queue</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_queue_name'>queue_name</span><span class='rparen'>)</span>
862
862
  <span class='kw'>end</span></pre>
863
863
  </td>
864
864
  </tr>
@@ -880,17 +880,17 @@ occur.</p>
880
880
  <pre class="lines">
881
881
 
882
882
 
883
- 110
884
883
  111
885
884
  112
886
885
  113
887
886
  114
888
887
  115
889
888
  116
890
- 117</pre>
889
+ 117
890
+ 118</pre>
891
891
  </td>
892
892
  <td>
893
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 110</span>
893
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 111</span>
894
894
 
895
895
  <span class='kw'>def</span> <span class='id identifier rubyid_publish'>publish</span><span class='lparen'>(</span><span class='id identifier rubyid_exchange'>exchange</span><span class='comma'>,</span> <span class='id identifier rubyid_routing_key'>routing_key</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
896
896
  <span class='id identifier rubyid_log'>log</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Isimud::TestClient: Delivering message exchange: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exchange'>exchange</span><span class='embexpr_end'>}</span><span class='tstring_content'> key: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_routing_key'>routing_key</span><span class='embexpr_end'>}</span><span class='tstring_content'> payload: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_payload'>payload</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
@@ -920,12 +920,12 @@ occur.</p>
920
920
  <pre class="lines">
921
921
 
922
922
 
923
- 123
924
923
  124
925
- 125</pre>
924
+ 125
925
+ 126</pre>
926
926
  </td>
927
927
  <td>
928
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 123</span>
928
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 124</span>
929
929
 
930
930
  <span class='kw'>def</span> <span class='id identifier rubyid_reconnect'>reconnect</span>
931
931
  <span class='kw'>self</span>
@@ -950,12 +950,12 @@ occur.</p>
950
950
  <pre class="lines">
951
951
 
952
952
 
953
- 119
954
953
  120
955
- 121</pre>
954
+ 121
955
+ 122</pre>
956
956
  </td>
957
957
  <td>
958
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 119</span>
958
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 120</span>
959
959
 
960
960
  <span class='kw'>def</span> <span class='id identifier rubyid_reset'>reset</span>
961
961
  <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_queues'>queues</span><span class='period'>.</span><span class='id identifier rubyid_clear'>clear</span>
@@ -980,13 +980,13 @@ occur.</p>
980
980
  <pre class="lines">
981
981
 
982
982
 
983
- 105
984
983
  106
985
984
  107
986
- 108</pre>
985
+ 108
986
+ 109</pre>
987
987
  </td>
988
988
  <td>
989
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 105</span>
989
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 106</span>
990
990
 
991
991
  <span class='kw'>def</span> <span class='id identifier rubyid_subscribe'>subscribe</span><span class='lparen'>(</span><span class='id identifier rubyid_queue'>queue</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
992
992
  <span class='id identifier rubyid_queue'>queue</span><span class='period'>.</span><span class='id identifier rubyid_proc'>proc</span> <span class='op'>=</span> <span class='id identifier rubyid_block'>block</span>
@@ -1002,7 +1002,7 @@ occur.</p>
1002
1002
  </div>
1003
1003
 
1004
1004
  <div id="footer">
1005
- Generated on Wed Jan 13 16:27:29 2016 by
1005
+ Generated on Mon Jan 18 17:07:52 2016 by
1006
1006
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1007
1007
  0.8.7.6 (ruby-2.2.3).
1008
1008
  </div>
@@ -321,7 +321,7 @@
321
321
  <li class="public ">
322
322
  <span class="summary_signature">
323
323
 
324
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (Queue) <strong>initialize</strong>(name, proc = Proc.new{ |_| }) </a>
324
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Queue) <strong>initialize</strong>(client, name, proc = Proc.new{ |_| }) </a>
325
325
 
326
326
 
327
327
 
@@ -408,7 +408,7 @@
408
408
  <div class="method_details first">
409
409
  <h3 class="signature first" id="initialize-instance_method">
410
410
 
411
- - (<tt><span class='object_link'><a href="" title="Isimud::TestClient::Queue (class)">Queue</a></span></tt>) <strong>initialize</strong>(name, proc = Proc.new{ |_| })
411
+ - (<tt><span class='object_link'><a href="" title="Isimud::TestClient::Queue (class)">Queue</a></span></tt>) <strong>initialize</strong>(client, name, proc = Proc.new{ |_| })
412
412
 
413
413
 
414
414
 
@@ -435,12 +435,14 @@
435
435
  18
436
436
  19
437
437
  20
438
- 21</pre>
438
+ 21
439
+ 22</pre>
439
440
  </td>
440
441
  <td>
441
442
  <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 17</span>
442
443
 
443
- <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_proc'>proc</span> <span class='op'>=</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='rbrace'>}</span> <span class='rparen'>)</span>
444
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_client'>client</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_proc'>proc</span> <span class='op'>=</span> <span class='const'>Proc</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid__'>_</span><span class='op'>|</span> <span class='rbrace'>}</span> <span class='rparen'>)</span>
445
+ <span class='ivar'>@client</span> <span class='op'>=</span> <span class='id identifier rubyid_client'>client</span>
444
446
  <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
445
447
  <span class='ivar'>@bindings</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='rbrace'>}</span>
446
448
  <span class='ivar'>@proc</span> <span class='op'>=</span> <span class='id identifier rubyid_proc'>proc</span>
@@ -606,14 +608,14 @@
606
608
  <pre class="lines">
607
609
 
608
610
 
609
- 23
610
611
  24
611
612
  25
612
613
  26
613
- 27</pre>
614
+ 27
615
+ 28</pre>
614
616
  </td>
615
617
  <td>
616
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 23</span>
618
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 24</span>
617
619
 
618
620
  <span class='kw'>def</span> <span class='id identifier rubyid_bind'>bind</span><span class='lparen'>(</span><span class='id identifier rubyid_exchange'>exchange</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
619
621
  <span class='id identifier rubyid_routing_key'>routing_key</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:routing_key</span><span class='rbracket'>]</span>
@@ -640,12 +642,12 @@
640
642
  <pre class="lines">
641
643
 
642
644
 
643
- 29
644
645
  30
645
- 31</pre>
646
+ 31
647
+ 32</pre>
646
648
  </td>
647
649
  <td>
648
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 29</span>
650
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 30</span>
649
651
 
650
652
  <span class='kw'>def</span> <span class='id identifier rubyid_cancel'>cancel</span>
651
653
  <span class='ivar'>@proc</span> <span class='op'>=</span> <span class='kw'>nil</span>
@@ -670,14 +672,14 @@
670
672
  <pre class="lines">
671
673
 
672
674
 
673
- 33
674
675
  34
675
676
  35
676
677
  36
677
- 37</pre>
678
+ 37
679
+ 38</pre>
678
680
  </td>
679
681
  <td>
680
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 33</span>
682
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 34</span>
681
683
 
682
684
  <span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
683
685
  <span class='id identifier rubyid_log'>log</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>TestClient: delete queue </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
@@ -704,24 +706,24 @@
704
706
  <pre class="lines">
705
707
 
706
708
 
707
- 53
708
709
  54
709
710
  55
710
711
  56
711
712
  57
712
713
  58
713
714
  59
714
- 60</pre>
715
+ 60
716
+ 61</pre>
715
717
  </td>
716
718
  <td>
717
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 53</span>
719
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 54</span>
718
720
 
719
721
  <span class='kw'>def</span> <span class='id identifier rubyid_deliver'>deliver</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
720
722
  <span class='kw'>begin</span>
721
723
  <span class='ivar'>@proc</span><span class='period'>.</span><span class='id identifier rubyid_try'>try</span><span class='lparen'>(</span><span class='symbol'>:call</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='rparen'>)</span>
722
724
  <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
723
725
  <span class='id identifier rubyid_log'>log</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>TestClient: error delivering message: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_content'>\n </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_backtrace'>backtrace</span><span class='period'>.</span><span class='id identifier rubyid_join'>join</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\n </span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:error</span>
724
- <span class='id identifier rubyid_run_exception_handlers'>run_exception_handlers</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
726
+ <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_run_exception_handlers'>run_exception_handlers</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
725
727
  <span class='kw'>end</span>
726
728
  <span class='kw'>end</span></pre>
727
729
  </td>
@@ -766,12 +768,12 @@
766
768
  <pre class="lines">
767
769
 
768
770
 
769
- 49
770
771
  50
771
- 51</pre>
772
+ 51
773
+ 52</pre>
772
774
  </td>
773
775
  <td>
774
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 49</span>
776
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 50</span>
775
777
 
776
778
  <span class='kw'>def</span> <span class='id identifier rubyid_has_matching_key?'>has_matching_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_exchange'>exchange</span><span class='comma'>,</span> <span class='id identifier rubyid_route'>route</span><span class='rparen'>)</span>
777
779
  <span class='ivar'>@bindings</span><span class='lbracket'>[</span><span class='id identifier rubyid_exchange'>exchange</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='op'>|</span> <span class='id identifier rubyid_route'>route</span> <span class='op'>=~</span> <span class='id identifier rubyid_make_regexp'>make_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
@@ -796,12 +798,12 @@
796
798
  <pre class="lines">
797
799
 
798
800
 
799
- 45
800
801
  46
801
- 47</pre>
802
+ 47
803
+ 48</pre>
802
804
  </td>
803
805
  <td>
804
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 45</span>
806
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 46</span>
805
807
 
806
808
  <span class='kw'>def</span> <span class='id identifier rubyid_make_regexp'>make_regexp</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
807
809
  <span class='const'>Regexp</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\.</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\*</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>.*</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span><span class='rparen'>)</span>
@@ -826,14 +828,14 @@
826
828
  <pre class="lines">
827
829
 
828
830
 
829
- 39
830
831
  40
831
832
  41
832
833
  42
833
- 43</pre>
834
+ 43
835
+ 44</pre>
834
836
  </td>
835
837
  <td>
836
- <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 39</span>
838
+ <pre class="code"><span class="info file"># File 'lib/isimud/test_client.rb', line 40</span>
837
839
 
838
840
  <span class='kw'>def</span> <span class='id identifier rubyid_unbind'>unbind</span><span class='lparen'>(</span><span class='id identifier rubyid_exchange'>exchange</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
839
841
  <span class='id identifier rubyid_routing_key'>routing_key</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:routing_key</span><span class='rbracket'>]</span>
@@ -850,7 +852,7 @@
850
852
  </div>
851
853
 
852
854
  <div id="footer">
853
- Generated on Wed Jan 13 16:27:29 2016 by
855
+ Generated on Mon Jan 18 17:07:52 2016 by
854
856
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
855
857
  0.8.7.6 (ruby-2.2.3).
856
858
  </div>
@@ -284,7 +284,7 @@
284
284
  </div>
285
285
 
286
286
  <div id="footer">
287
- Generated on Wed Jan 13 16:27:28 2016 by
287
+ Generated on Mon Jan 18 17:07:51 2016 by
288
288
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
289
289
  0.8.7.6 (ruby-2.2.3).
290
290
  </div>
@@ -64,7 +64,7 @@
64
64
  <div id="content"><div id='filecontents'>Copyright (c) 2016 Keas Inc.<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy<br/>of this software and associated documentation files (the &quot;Software&quot;), to deal<br/>in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>copies of the Software, and to permit persons to whom the Software is<br/>furnished to do so, subject to the following conditions:<br/><br/>The above copyright notice and this permission notice shall be included in all<br/>copies or substantial portions of the Software.<br/><br/>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>SOFTWARE.</div></div>
65
65
 
66
66
  <div id="footer">
67
- Generated on Wed Jan 13 16:27:28 2016 by
67
+ Generated on Mon Jan 18 17:07:52 2016 by
68
68
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
69
69
  0.8.7.6 (ruby-2.2.3).
70
70
  </div>
@@ -162,6 +162,13 @@ messages. Named queues are automatically created if they do not exist.</p>
162
162
 
163
163
  <h2 id="label-Changes">Changes</h2>
164
164
 
165
+ <h3 id="label-1.3.2">1.3.2</h3>
166
+ <ul><li>
167
+ <p>Fixed handling of exceptions in TestClient</p>
168
+ </li><li>
169
+ <p>Make EventListener#has_observer? public</p>
170
+ </li></ul>
171
+
165
172
  <h3 id="label-1.3.1">1.3.1</h3>
166
173
  <ul><li>
167
174
  <p>Add EventObserver#deactivate_observer to trigger queue deletion for an
@@ -453,7 +460,7 @@ feature&#39;</code>)</p>
453
460
  </div></div>
454
461
 
455
462
  <div id="footer">
456
- Generated on Wed Jan 13 16:27:28 2016 by
463
+ Generated on Mon Jan 18 17:07:52 2016 by
457
464
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
458
465
  0.8.7.6 (ruby-2.2.3).
459
466
  </div>
@@ -162,6 +162,13 @@ messages. Named queues are automatically created if they do not exist.</p>
162
162
 
163
163
  <h2 id="label-Changes">Changes</h2>
164
164
 
165
+ <h3 id="label-1.3.2">1.3.2</h3>
166
+ <ul><li>
167
+ <p>Fixed handling of exceptions in TestClient</p>
168
+ </li><li>
169
+ <p>Make EventListener#has_observer? public</p>
170
+ </li></ul>
171
+
165
172
  <h3 id="label-1.3.1">1.3.1</h3>
166
173
  <ul><li>
167
174
  <p>Add EventObserver#deactivate_observer to trigger queue deletion for an
@@ -453,7 +460,7 @@ feature&#39;</code>)</p>
453
460
  </div></div>
454
461
 
455
462
  <div id="footer">
456
- Generated on Wed Jan 13 16:27:28 2016 by
463
+ Generated on Mon Jan 18 17:07:52 2016 by
457
464
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
458
465
  0.8.7.6 (ruby-2.2.3).
459
466
  </div>
@@ -103,7 +103,7 @@
103
103
  </div>
104
104
 
105
105
  <div id="footer">
106
- Generated on Wed Jan 13 16:27:29 2016 by
106
+ Generated on Mon Jan 18 17:07:52 2016 by
107
107
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
108
108
  0.8.7.6 (ruby-2.2.3).
109
109
  </div>
@@ -16,7 +16,7 @@ Isimud is an AMQP message publishing and consumption gem that is intended for ma
16
16
  * A test client which mocks most client operations and allows for synchronous delivery and processing of messages for unit tests.
17
17
  * A Model Watcher mixin for ActiveRecord that automatically sends messages whenever an ActiveRecord instance is created, modified, or destroyed.
18
18
  * An Event Observer mixin for registering ActiveRecord models and instances with the EventListener for receiving messages.
19
- * An Event Listener daemon process which manages queues and dispatches messages for Event Observers.
19
+ * An Event Listener daemon process which manages queues and dispatches messages for Event Observers and other consumers.
20
20
  EOT
21
21
  spec.homepage = 'https://github.com/KeasInc/isimud'
22
22
  spec.license = 'MITNFA'
@@ -43,21 +43,21 @@ module Isimud
43
43
  # Whenever a Bunny exception is rescued in the event processing thread, the Bunny session is closed (canceling all
44
44
  # queue consumers), in addition to the error being counted, all Bunny channels are closed, and queues are
45
45
  # reinitialized.
46
- class EventListener
46
+ class EventListener
47
47
  include Logging
48
48
 
49
- # @!attribute [r] error_count
50
- # @return [Integer] count of errors (uncaught exceptions) that have occurred in the current error interval
49
+ attr_reader :error_count, :error_interval, :error_limit, :name, :queues, :events_exchange, :models_exchange, :status
51
50
 
52
- attr_reader :error_count, :error_interval, :error_limit, :name, :queues, :events_exchange, :models_exchange,
53
- :running
54
-
55
- DEFAULT_ERROR_LIMIT = 10
56
- DEFAULT_ERROR_INTERVAL = 3600
51
+ DEFAULT_ERROR_LIMIT = 10
52
+ DEFAULT_ERROR_INTERVAL = 3600
57
53
 
58
54
  DEFAULT_EVENTS_EXCHANGE = 'events'
59
55
  DEFAULT_MODELS_EXCHANGE = 'models'
60
56
 
57
+ STATUS_INITIALIZE = :initialize
58
+ STATUS_RUNNING = :running
59
+ STATUS_SHUTDOWN = :shutdown
60
+
61
61
  # Initialize a new EventListener daemon instance
62
62
  # @param [Hash] options daemon options
63
63
  # @option options [Integer] :error_limit (10) maximum number of errors that are allowed to occur within error_interval
@@ -69,29 +69,28 @@ class EventListener
69
69
  # @option options [String] :name ("#{Rails.application.class.parent_name.downcase}-listener") daemon instance name.
70
70
  def initialize(options = {})
71
71
  default_options = {
72
- error_limit: Isimud.listener_error_limit || DEFAULT_ERROR_LIMIT,
73
- error_interval: DEFAULT_ERROR_INTERVAL,
74
- events_exchange: Isimud.events_exchange || DEFAULT_EVENTS_EXCHANGE,
75
- models_exchange: Isimud.model_watcher_exchange || DEFAULT_MODELS_EXCHANGE,
76
- name: "#{Rails.application.class.parent_name.downcase}-listener"
72
+ error_limit: Isimud.listener_error_limit || DEFAULT_ERROR_LIMIT,
73
+ error_interval: DEFAULT_ERROR_INTERVAL,
74
+ events_exchange: Isimud.events_exchange || DEFAULT_EVENTS_EXCHANGE,
75
+ models_exchange: Isimud.model_watcher_exchange || DEFAULT_MODELS_EXCHANGE,
76
+ name: "#{Rails.application.class.parent_name.downcase}-listener"
77
77
  }
78
78
  options.reverse_merge!(default_options)
79
- @error_count = 0
80
- @observers = Hash.new
81
- @observed_models = Set.new
82
- @error_limit = options[:error_limit]
83
- @error_interval = options[:error_interval]
84
- @events_exchange = options[:events_exchange]
85
- @models_exchange = options[:models_exchange]
86
- @name = options[:name]
87
- @observer_mutex = Mutex.new
88
- @error_counter_mutex = Mutex.new
89
- @running = false
79
+ @error_count = 0
80
+ @observers = Hash.new
81
+ @observed_models = Set.new
82
+ @error_limit = options[:error_limit]
83
+ @error_interval = options[:error_interval]
84
+ @events_exchange = options[:events_exchange]
85
+ @models_exchange = options[:models_exchange]
86
+ @name = options[:name]
87
+ @observer_mutex = Mutex.new
88
+ @error_counter_mutex = Mutex.new
89
+ @status = STATUS_INITIALIZE
90
90
  end
91
91
 
92
92
  # Run the daemon process. This creates the event, error counter, and shutdown threads
93
93
  def run
94
- @running = true
95
94
  bind_queues and return if test_env?
96
95
  start_shutdown_thread
97
96
  start_error_counter_thread
@@ -117,6 +116,11 @@ class EventListener
117
116
  bind_event_queues
118
117
  end
119
118
 
119
+ # @private
120
+ def has_observer?(observer)
121
+ @observers.has_key?(observer_key_for(observer.class, observer.id))
122
+ end
123
+
120
124
  private
121
125
 
122
126
  def test_env?
@@ -139,15 +143,11 @@ class EventListener
139
143
  end
140
144
  end
141
145
 
142
- def has_observer?(observer)
143
- @observers.has_key?(observer_key_for(observer.class, observer.id))
144
- end
145
-
146
146
  def start_shutdown_thread
147
147
  shutdown_thread = Thread.new do
148
148
  Thread.stop # wait until we get a TERM or INT signal.
149
149
  log 'EventListener: shutdown requested. Shutting down AMQP...', :info
150
- @running = false
150
+ @status = STATUS_SHUTDOWN
151
151
  Thread.main.run
152
152
  end
153
153
  %w(SIGINT SIGTERM).each { |sig| trap(sig) { shutdown_thread.wakeup } }
@@ -157,15 +157,28 @@ class EventListener
157
157
  Isimud.client
158
158
  end
159
159
 
160
+ def initializing?
161
+ status == STATUS_INITIALIZE
162
+ end
163
+
164
+ def running?
165
+ status == STATUS_RUNNING
166
+ end
167
+
168
+ def shutdown?
169
+ status == STATUS_SHUTDOWN
170
+ end
171
+
160
172
  def start_event_thread
161
173
  Thread.new do
162
174
  log 'EventListener: starting event_thread'
163
- while @running
175
+ until shutdown? do
164
176
  begin
165
177
  bind_queues
166
178
  log 'EventListener: event_thread finished'
179
+ @status = STATUS_RUNNING
167
180
  Thread.stop
168
- rescue Bunny::Exception => e
181
+ rescue => e
169
182
  count_error(e)
170
183
  log 'EventListener: resetting queues', :warn
171
184
  @observer_queue = nil
@@ -181,7 +194,7 @@ class EventListener
181
194
  log "EventListener#count_error count = #{@error_count} limit=#{error_limit}", :warn
182
195
  if (@error_count >= error_limit)
183
196
  log 'EventListener: too many errors, exiting', :fatal
184
- @running = false
197
+ @status = STATUS_SHUTDOWN
185
198
  Thread.main.run unless test_env?
186
199
  end
187
200
  end
@@ -202,7 +215,7 @@ class EventListener
202
215
  end
203
216
 
204
217
  def handle_observer_event(payload)
205
- event = JSON.parse(payload).with_indifferent_access
218
+ event = JSON.parse(payload).with_indifferent_access
206
219
  action = event[:action]
207
220
  log "EventListener: received observer model message: #{event.inspect}"
208
221
  if %w(update destroy).include?(action)
@@ -229,7 +242,7 @@ class EventListener
229
242
  def register_observer(observer)
230
243
  @observer_mutex.synchronize do
231
244
  log "EventListener: registering observer #{observer.class} #{observer.id}"
232
- @observers[observer_key_for(observer.class, observer.id)] = observer.observe_events(client)
245
+ @observers[observer_key_for(observer.class, observer.id)] = observer.observe_events(client, initializing?)
233
246
  end
234
247
  end
235
248
 
@@ -247,8 +260,8 @@ class EventListener
247
260
  def observer_queue
248
261
  @observer_queue ||= client.create_queue([name, 'listener', Socket.gethostname, Process.pid].join('.'),
249
262
  models_exchange,
250
- queue_options: {exclusive: true},
251
- subscribe_options: {manual_ack: true})
263
+ queue_options: {exclusive: true},
264
+ subscribe_options: {manual_ack: true})
252
265
  end
253
266
 
254
267
  def observer_key_for(type, id)
@@ -52,10 +52,14 @@ module Isimud
52
52
 
53
53
  # Create or attach to a queue on the specified exchange. When an event message that matches the observer's routing keys
54
54
  # is received, parse the event and call handle_event on same.
55
- # Returns the consumer for the observer
56
- def observe_events(client)
55
+ # @param [Isimud::Client] client client instance
56
+ # @param [Boolean] refresh_bindings when set, refresh bindings on queue (true)
57
+ # @return queue or consumer object
58
+ # @see BunnyClient#subscribe
59
+ # @see TestClient#subscribe
60
+ def observe_events(client, refresh_bindings = true)
57
61
  return unless enable_listener?
58
- queue = client.kind_of?(Isimud::TestClient) ? create_queue(client) : client.find_queue(event_queue_name)
62
+ queue = (refresh_bindings || client.kind_of?(Isimud::TestClient)) ? create_queue(client) : client.find_queue(event_queue_name)
59
63
  client.subscribe(queue) do |message|
60
64
  event = Event.parse(message)
61
65
  handle_event(event)
@@ -102,14 +106,15 @@ module Isimud
102
106
  queue = isimud_client.find_queue(event_queue_name)
103
107
  exchange = observed_exchange || Isimud.events_exchange
104
108
  (prev_keys - current_keys).each { |key| queue.unbind(exchange, routing_key: key) }
109
+ log "Isimud::EventObserver: binding queue #{event_queue_name} on exchange #{exchange} with bindings [#{current_keys.join(',')}]"
105
110
  (current_keys).each { |key| queue.bind(exchange, routing_key: key) }
106
111
  else
107
112
  isimud_client.delete_queue(event_queue_name)
108
113
  end
109
114
  end
110
115
 
111
- def delete_queue
112
- isimud_client.delete_queue(event_queue_name)
116
+ def delete_queue(client = isimud_client)
117
+ client.delete_queue(event_queue_name)
113
118
  end
114
119
 
115
120
  def set_routing_keys
@@ -137,7 +137,7 @@ module Isimud
137
137
  }
138
138
  payload[:attributes] = isimud_attribute_data
139
139
  routing_key = isimud_model_watcher_routing_key(action)
140
- log "Isimud::ModelWatcher#publish: exchange #{isimud_model_watcher_exchange} routing_key #{routing_key} payload #{payload.inspect}"
140
+ log "Isimud::ModelWatcher#publish: exchange=#{isimud_model_watcher_exchange} routing_key=#{routing_key} id=#{id}"
141
141
  Isimud.client.publish(isimud_model_watcher_exchange, routing_key, payload.to_json)
142
142
  end
143
143
  end
@@ -11,10 +11,11 @@ module Isimud
11
11
 
12
12
  class Queue
13
13
  include Isimud::Logging
14
- attr_reader :name, :bindings
14
+ attr_reader :name, :bindings, :client
15
15
  attr_accessor :proc
16
16
 
17
- def initialize(name, proc = Proc.new{ |_| } )
17
+ def initialize(client, name, proc = Proc.new{ |_| } )
18
+ @client = client
18
19
  @name = name
19
20
  @bindings = Hash.new{ |hash, key| hash[key] = Set.new }
20
21
  @proc = proc
@@ -55,7 +56,7 @@ module Isimud
55
56
  @proc.try(:call, data)
56
57
  rescue => e
57
58
  log "TestClient: error delivering message: #{e.message}\n #{e.backtrace.join("\n ")}", :error
58
- run_exception_handlers(e)
59
+ client.run_exception_handlers(e)
59
60
  end
60
61
  end
61
62
  end
@@ -89,7 +90,7 @@ module Isimud
89
90
  end
90
91
 
91
92
  def find_queue(queue_name, options = {})
92
- queues[queue_name] ||= Queue.new(queue_name)
93
+ queues[queue_name] ||= Queue.new(self, queue_name)
93
94
  end
94
95
 
95
96
  def create_queue(queue_name, exchange_name, options = {})
@@ -1,3 +1,3 @@
1
1
  module Isimud
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isimud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Feil
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-14 00:00:00.000000000 Z
12
+ date: 2016-08-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -74,7 +74,7 @@ description: |
74
74
  * A test client which mocks most client operations and allows for synchronous delivery and processing of messages for unit tests.
75
75
  * A Model Watcher mixin for ActiveRecord that automatically sends messages whenever an ActiveRecord instance is created, modified, or destroyed.
76
76
  * An Event Observer mixin for registering ActiveRecord models and instances with the EventListener for receiving messages.
77
- * An Event Listener daemon process which manages queues and dispatches messages for Event Observers.
77
+ * An Event Listener daemon process which manages queues and dispatches messages for Event Observers and other consumers.
78
78
  email:
79
79
  - george.feil@keas.com
80
80
  - bonkydog@bonkydog.com