isimud 0.7.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -2
  4. data/.ruby-version +1 -1
  5. data/.yardoc/checksums +10 -10
  6. data/.yardoc/object_types +0 -0
  7. data/.yardoc/objects/root.dat +0 -0
  8. data/Gemfile +2 -1
  9. data/Gemfile.lock +63 -73
  10. data/LICENSE.txt +19 -0
  11. data/README.md +51 -3
  12. data/Rakefile +5 -0
  13. data/doc/Isimud/BunnyClient.html +882 -179
  14. data/doc/Isimud/Client.html +236 -18
  15. data/doc/Isimud/Event.html +211 -95
  16. data/doc/Isimud/EventListener.html +325 -307
  17. data/doc/Isimud/EventObserver/ClassMethods.html +14 -14
  18. data/doc/Isimud/EventObserver.html +418 -36
  19. data/doc/Isimud/Generators/ConfigGenerator.html +2 -2
  20. data/doc/Isimud/Generators/InitializerGenerator.html +2 -2
  21. data/doc/Isimud/Generators.html +2 -2
  22. data/doc/Isimud/Logging.html +3 -3
  23. data/doc/Isimud/ModelWatcher/ClassMethods.html +3 -3
  24. data/doc/Isimud/ModelWatcher.html +2 -2
  25. data/doc/Isimud/Railtie.html +2 -2
  26. data/doc/Isimud/TestClient/Queue.html +374 -71
  27. data/doc/Isimud/TestClient.html +169 -161
  28. data/doc/Isimud.html +80 -76
  29. data/doc/_index.html +5 -2
  30. data/doc/file.LICENSE.html +73 -0
  31. data/doc/file.README.html +131 -7
  32. data/doc/file_list.html +3 -0
  33. data/doc/index.html +131 -7
  34. data/doc/method_list.html +183 -105
  35. data/doc/top-level-namespace.html +2 -2
  36. data/isimud.gemspec +18 -16
  37. data/lib/isimud/bunny_client.rb +85 -32
  38. data/lib/isimud/client.rb +23 -7
  39. data/lib/isimud/event.rb +11 -14
  40. data/lib/isimud/event_listener.rb +123 -65
  41. data/lib/isimud/event_observer.rb +70 -10
  42. data/lib/isimud/model_watcher.rb +1 -1
  43. data/lib/isimud/test_client.rb +54 -26
  44. data/lib/isimud/version.rb +1 -1
  45. data/lib/isimud.rb +1 -1
  46. data/spec/internal/app/models/company.rb +8 -10
  47. data/spec/internal/app/models/user.rb +11 -1
  48. data/spec/internal/db/schema.rb +5 -0
  49. data/spec/isimud/bunny_client_spec.rb +21 -9
  50. data/spec/isimud/client_spec.rb +40 -0
  51. data/spec/isimud/event_listener_spec.rb +50 -22
  52. data/spec/isimud/event_observer_spec.rb +107 -16
  53. data/spec/isimud/model_watcher_spec.rb +18 -23
  54. data/spec/isimud/test_client_spec.rb +43 -8
  55. data/spec/isimud_spec.rb +2 -2
  56. data/spec/spec_helper.rb +2 -0
  57. metadata +19 -35
  58. checksums.yaml.gz.sig +0 -0
  59. data/certs/gfeil.pem +0 -21
  60. data/release +0 -31
  61. data.tar.gz.sig +0 -0
  62. metadata.gz.sig +0 -2
@@ -103,7 +103,80 @@
103
103
  </dl>
104
104
  <div class="clear"></div>
105
105
 
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+
109
+ <p>Daemon process manager for monitoring event queues. Known EventObserver
110
+ models and their instances automatically registered upon startup. It is
111
+ also possible to define ad-hoc queues and handlers by extending In
112
+ addition, ad-hoc event managing may be set up by extending bind_queues()
113
+ and making the appropriate subscribe calls directly.</p>
114
+
115
+ <h6 id="label-"></h6>
116
+
117
+ <p>Threads created by the daemon process</p>
118
+
119
+ <h6 id="label-"></h6>
120
+
121
+ <p>Upon startup, EventListener operates using the following threads:</p>
122
+ <ul><li>
123
+ <p>An event processing thread that establishes consumers for message queues</p>
124
+ </li><li>
125
+ <p>An error counter thread that manages the error counter</p>
126
+ </li><li>
127
+ <p>A shutdown thread that listens for INT or TERM signals, which will trigger
128
+ a graceful shutdown.</p>
129
+ </li><li>
130
+ <p>The main thread is put to sleep until a shutdown is required.</p>
131
+ </li></ul>
132
+
133
+ <h6 id="label-"></h6>
134
+
135
+ <p>Registering Queues</p>
136
+
137
+ <h6 id="label-"></h6>
138
+
139
+ <p>All active instances of all known EventObserver classes (which are assumed
140
+ to be ActiveRecord instances) are automatically loaded by the event
141
+ processing thread, and their associated queues are bound. Note that queues
142
+ and associated routing key bindings are established at the time the
143
+ instance is created or modified. Each EventListener process creates an
144
+ exclusive queue for monitoring the creation, modification, and destruction
145
+ of EventObserver instances, using ModelWatcher messages.</p>
146
+
147
+ <h6 id="label-"></h6>
148
+
149
+ <p>Error Handling</p>
150
+
151
+ <h6 id="label-"></h6>
152
+
153
+ <p>Whenever an uncaught exception is rescued from a consumer handling a
154
+ message, it is logged and the error counter is incremented. The error
155
+ counter is reset periodically according to the value of
156
+ <code>error_interval</code>. If the total number of errors logged exceeds
157
+ <code>error_limit</code>, the process is terminated immediately. There are
158
+ certain situations that may cause a Bunny exception to occur, such as a
159
+ loss of network connection. Whenever a Bunny exception is rescued in the
160
+ event processing thread, the Bunny session is closed (canceling all queue
161
+ consumers), in addition to the error being counted, all Bunny channels are
162
+ closed, and queues are reinitialized.</p>
163
+
164
+
165
+ </div>
166
+ </div>
167
+ <div class="tags">
168
+
106
169
 
170
+ <p class="tag_title">See Also:</p>
171
+ <ul class="see">
172
+
173
+ <li>EventObserver.find_active_observers</li>
174
+
175
+ <li>BunnyClient#subscribe()</li>
176
+
177
+ </ul>
178
+
179
+ </div>
107
180
  <h2>Constant Summary</h2>
108
181
 
109
182
  <dl class="constants">
@@ -111,7 +184,7 @@
111
184
  <dt id="DEFAULT_ERROR_LIMIT-constant" class="">DEFAULT_ERROR_LIMIT =
112
185
 
113
186
  </dt>
114
- <dd><pre class="code"><span class='int'>100</span></pre></dd>
187
+ <dd><pre class="code"><span class='int'>10</span></pre></dd>
115
188
 
116
189
  <dt id="DEFAULT_ERROR_INTERVAL-constant" class="">DEFAULT_ERROR_INTERVAL =
117
190
 
@@ -140,7 +213,7 @@
140
213
  <li class="public ">
141
214
  <span class="summary_signature">
142
215
 
143
- <a href="#error_count-instance_method" title="#error_count (instance method)">- (Object) <strong>error_count</strong> </a>
216
+ <a href="#error_count-instance_method" title="#error_count (instance method)">- (Integer) <strong>error_count</strong> </a>
144
217
 
145
218
 
146
219
 
@@ -160,7 +233,8 @@
160
233
 
161
234
 
162
235
  <span class="summary_desc"><div class='inline'>
163
- <p>Returns the value of attribute error_count.</p>
236
+ <p>Count of errors (uncaught exceptions) that have occurred in the current
237
+ error interval.</p>
164
238
  </div></span>
165
239
 
166
240
  </li>
@@ -385,7 +459,7 @@
385
459
  <li class="public ">
386
460
  <span class="summary_signature">
387
461
 
388
- <a href="#bind_queues-instance_method" title="#bind_queues (instance method)">- (Object) <strong>bind_queues</strong> </a>
462
+ <a href="#bind_event_queues-instance_method" title="#bind_event_queues (instance method)">- (Object) <strong>bind_event_queues</strong> </a>
389
463
 
390
464
 
391
465
 
@@ -400,31 +474,9 @@
400
474
 
401
475
 
402
476
  <span class="summary_desc"><div class='inline'>
403
- <p>Override this method to set up message observers.</p>
477
+ <p>Hook for setting up custom queues in your application.</p>
404
478
  </div></span>
405
479
 
406
- </li>
407
-
408
-
409
- <li class="public ">
410
- <span class="summary_signature">
411
-
412
- <a href="#has_observer%3F-instance_method" title="#has_observer? (instance method)">- (Boolean) <strong>has_observer?</strong>(observer) </a>
413
-
414
-
415
-
416
- </span>
417
-
418
-
419
-
420
-
421
-
422
-
423
-
424
-
425
-
426
- <span class="summary_desc"><div class='inline'></div></span>
427
-
428
480
  </li>
429
481
 
430
482
 
@@ -448,31 +500,9 @@
448
500
 
449
501
 
450
502
  <span class="summary_desc"><div class='inline'>
451
- <p>A new instance of EventListener.</p>
503
+ <p>Initialize a new EventListener daemon instance.</p>
452
504
  </div></span>
453
505
 
454
- </li>
455
-
456
-
457
- <li class="public ">
458
- <span class="summary_signature">
459
-
460
- <a href="#max_errors-instance_method" title="#max_errors (instance method)">- (Object) <strong>max_errors</strong> </a>
461
-
462
-
463
-
464
- </span>
465
-
466
-
467
-
468
-
469
-
470
-
471
-
472
-
473
-
474
- <span class="summary_desc"><div class='inline'></div></span>
475
-
476
506
  </li>
477
507
 
478
508
 
@@ -493,29 +523,9 @@
493
523
 
494
524
 
495
525
 
496
- <span class="summary_desc"><div class='inline'></div></span>
497
-
498
- </li>
499
-
500
-
501
- <li class="public ">
502
- <span class="summary_signature">
503
-
504
- <a href="#test_env%3F-instance_method" title="#test_env? (instance method)">- (Boolean) <strong>test_env?</strong> </a>
505
-
506
-
507
-
508
- </span>
509
-
510
-
511
-
512
-
513
-
514
-
515
-
516
-
517
-
518
- <span class="summary_desc"><div class='inline'></div></span>
526
+ <span class="summary_desc"><div class='inline'>
527
+ <p>Run the daemon process.</p>
528
+ </div></span>
519
529
 
520
530
  </li>
521
531
 
@@ -549,13 +559,126 @@
549
559
  </h3><div class="docstring">
550
560
  <div class="discussion">
551
561
 
552
- <p>Returns a new instance of EventListener</p>
562
+ <p>Initialize a new EventListener daemon instance</p>
553
563
 
554
564
 
555
565
  </div>
556
566
  </div>
557
567
  <div class="tags">
568
+ <p class="tag_title">Parameters:</p>
569
+ <ul class="param">
558
570
 
571
+ <li>
572
+
573
+ <span class='name'>options</span>
574
+
575
+
576
+ <span class='type'>(<tt>Hash</tt>)</span>
577
+
578
+
579
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
580
+
581
+
582
+ &mdash;
583
+ <div class='inline'>
584
+ <p>daemon options</p>
585
+ </div>
586
+
587
+ </li>
588
+
589
+ </ul>
590
+
591
+
592
+
593
+
594
+ <p class="tag_title">Options Hash (<tt>options</tt>):</p>
595
+ <ul class="option">
596
+
597
+ <li>
598
+ <span class="name">:error_limit</span>
599
+ <span class="type">(<tt>Integer</tt>)</span>
600
+ <span class="default">
601
+
602
+ &mdash; default:
603
+ <tt>10</tt>
604
+
605
+ </span>
606
+
607
+ &mdash; <div class='inline'>
608
+ <p>maximum number of errors that are allowed to occur within error_interval
609
+ before the process terminates</p>
610
+ </div>
611
+
612
+ </li>
613
+
614
+ <li>
615
+ <span class="name">:error_interval</span>
616
+ <span class="type">(<tt>Integer</tt>)</span>
617
+ <span class="default">
618
+
619
+ &mdash; default:
620
+ <tt>3600</tt>
621
+
622
+ </span>
623
+
624
+ &mdash; <div class='inline'>
625
+ <p>time interval, in seconds, before the error counter is cleared</p>
626
+ </div>
627
+
628
+ </li>
629
+
630
+ <li>
631
+ <span class="name">:events_exchange</span>
632
+ <span class="type">(<tt>String</tt>)</span>
633
+ <span class="default">
634
+
635
+ &mdash; default:
636
+ <tt>&#39;events&#39;</tt>
637
+
638
+ </span>
639
+
640
+ &mdash; <div class='inline'>
641
+ <p>name of AMQP exchange used for listening to event messages</p>
642
+ </div>
643
+
644
+ </li>
645
+
646
+ <li>
647
+ <span class="name">:models_exchange</span>
648
+ <span class="type">(<tt>String</tt>)</span>
649
+ <span class="default">
650
+
651
+ &mdash; default:
652
+ <tt>&#39;models&#39;</tt>
653
+
654
+ </span>
655
+
656
+ &mdash; <div class='inline'>
657
+ <p>name of AMQP exchange used for listening to EventObserver instance create,
658
+ update, and destroy messages</p>
659
+ </div>
660
+
661
+ </li>
662
+
663
+ <li>
664
+ <span class="name">:name</span>
665
+ <span class="type">(<tt>String</tt>)</span>
666
+ <span class="default">
667
+
668
+ &mdash; default:
669
+ <tt>&quot;#{Rails.application.class.parent_name.downcase}-listener&quot;</tt>
670
+
671
+ </span>
672
+
673
+ &mdash; <div class='inline'>
674
+ <p>daemon instance name.</p>
675
+ </div>
676
+
677
+ </li>
678
+
679
+ </ul>
680
+
681
+
559
682
 
560
683
  </div><table class="source_code">
561
684
  <tr>
@@ -563,49 +686,51 @@
563
686
  <pre class="lines">
564
687
 
565
688
 
566
- 16
567
- 17
568
- 18
569
- 19
570
- 20
571
- 21
572
- 22
573
- 23
574
- 24
575
- 25
576
- 26
577
- 27
578
- 28
579
- 29
580
- 30
581
- 31
582
- 32
583
- 33
584
- 34
585
- 35</pre>
689
+ 70
690
+ 71
691
+ 72
692
+ 73
693
+ 74
694
+ 75
695
+ 76
696
+ 77
697
+ 78
698
+ 79
699
+ 80
700
+ 81
701
+ 82
702
+ 83
703
+ 84
704
+ 85
705
+ 86
706
+ 87
707
+ 88
708
+ 89
709
+ 90</pre>
586
710
  </td>
587
711
  <td>
588
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 16</span>
712
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 70</span>
589
713
 
590
714
  <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</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>
591
715
  <span class='id identifier rubyid_default_options'>default_options</span> <span class='op'>=</span> <span class='lbrace'>{</span>
592
- <span class='label'>error_limit:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_listener_error_limit'>listener_error_limit</span> <span class='op'>||</span> <span class='const'>DEFAULT_ERROR_LIMIT</span><span class='comma'>,</span>
593
- <span class='label'>error_interval:</span> <span class='const'>DEFAULT_ERROR_INTERVAL</span><span class='comma'>,</span>
594
- <span class='label'>events_exchange:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_events_exchange'>events_exchange</span> <span class='op'>||</span> <span class='const'>DEFAULT_EVENTS_EXCHANGE</span><span class='comma'>,</span>
595
- <span class='label'>models_exchange:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_model_watcher_exchange'>model_watcher_exchange</span> <span class='op'>||</span> <span class='const'>DEFAULT_MODELS_EXCHANGE</span><span class='comma'>,</span>
596
- <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_parent_name'>parent_name</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>-listener</span><span class='tstring_end'>&quot;</span></span>
716
+ <span class='label'>error_limit:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_listener_error_limit'>listener_error_limit</span> <span class='op'>||</span> <span class='const'>DEFAULT_ERROR_LIMIT</span><span class='comma'>,</span>
717
+ <span class='label'>error_interval:</span> <span class='const'>DEFAULT_ERROR_INTERVAL</span><span class='comma'>,</span>
718
+ <span class='label'>events_exchange:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_events_exchange'>events_exchange</span> <span class='op'>||</span> <span class='const'>DEFAULT_EVENTS_EXCHANGE</span><span class='comma'>,</span>
719
+ <span class='label'>models_exchange:</span> <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_model_watcher_exchange'>model_watcher_exchange</span> <span class='op'>||</span> <span class='const'>DEFAULT_MODELS_EXCHANGE</span><span class='comma'>,</span>
720
+ <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_parent_name'>parent_name</span><span class='period'>.</span><span class='id identifier rubyid_downcase'>downcase</span><span class='embexpr_end'>}</span><span class='tstring_content'>-listener</span><span class='tstring_end'>&quot;</span></span>
597
721
  <span class='rbrace'>}</span>
598
722
  <span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_reverse_merge!'>reverse_merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_default_options'>default_options</span><span class='rparen'>)</span>
599
- <span class='ivar'>@error_count</span> <span class='op'>=</span> <span class='int'>0</span>
600
- <span class='ivar'>@observers</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
601
- <span class='ivar'>@observed_models</span> <span class='op'>=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
602
- <span class='ivar'>@events_exchange</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:events_exchange</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>DEFAULT_EVENTS_EXCHANGE</span>
603
- <span class='ivar'>@models_exchange</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:models_exchange</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>DEFAULT_MODELS_EXCHANGE</span>
604
- <span class='ivar'>@error_limit</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:error_limit</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>DEFAULT_ERROR_LIMIT</span>
605
- <span class='ivar'>@error_interval</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:error_interval</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='const'>DEFAULT_ERROR_INTERVAL</span>
606
- <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
607
- <span class='ivar'>@observer_mutex</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
608
- <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>false</span>
723
+ <span class='ivar'>@error_count</span> <span class='op'>=</span> <span class='int'>0</span>
724
+ <span class='ivar'>@observers</span> <span class='op'>=</span> <span class='const'>Hash</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
725
+ <span class='ivar'>@observed_models</span> <span class='op'>=</span> <span class='const'>Set</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
726
+ <span class='ivar'>@error_limit</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:error_limit</span><span class='rbracket'>]</span>
727
+ <span class='ivar'>@error_interval</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:error_interval</span><span class='rbracket'>]</span>
728
+ <span class='ivar'>@events_exchange</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:events_exchange</span><span class='rbracket'>]</span>
729
+ <span class='ivar'>@models_exchange</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:models_exchange</span><span class='rbracket'>]</span>
730
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:name</span><span class='rbracket'>]</span>
731
+ <span class='ivar'>@observer_mutex</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
732
+ <span class='ivar'>@error_counter_mutex</span> <span class='op'>=</span> <span class='const'>Mutex</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
733
+ <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>false</span>
609
734
  <span class='kw'>end</span></pre>
610
735
  </td>
611
736
  </tr>
@@ -622,7 +747,7 @@
622
747
  <div class="method_details first">
623
748
  <h3 class="signature first" id="error_count-instance_method">
624
749
 
625
- - (<tt>Object</tt>) <strong>error_count</strong> <span class="extras">(readonly)</span>
750
+ - (<tt>Integer</tt>) <strong>error_count</strong> <span class="extras">(readonly)</span>
626
751
 
627
752
 
628
753
 
@@ -631,13 +756,33 @@
631
756
  </h3><div class="docstring">
632
757
  <div class="discussion">
633
758
 
634
- <p>Returns the value of attribute error_count</p>
759
+ <p>Returns count of errors (uncaught exceptions) that have occurred in the
760
+ current error interval</p>
635
761
 
636
762
 
637
763
  </div>
638
764
  </div>
639
765
  <div class="tags">
640
766
 
767
+ <p class="tag_title">Returns:</p>
768
+ <ul class="return">
769
+
770
+ <li>
771
+
772
+
773
+ <span class='type'>(<tt>Integer</tt>)</span>
774
+
775
+
776
+
777
+ &mdash;
778
+ <div class='inline'>
779
+ <p>count of errors (uncaught exceptions) that have occurred in the current
780
+ error interval</p>
781
+ </div>
782
+
783
+ </li>
784
+
785
+ </ul>
641
786
 
642
787
  </div><table class="source_code">
643
788
  <tr>
@@ -645,12 +790,12 @@
645
790
  <pre class="lines">
646
791
 
647
792
 
648
- 7
649
- 8
650
- 9</pre>
793
+ 52
794
+ 53
795
+ 54</pre>
651
796
  </td>
652
797
  <td>
653
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
798
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
654
799
 
655
800
  <span class='kw'>def</span> <span class='id identifier rubyid_error_count'>error_count</span>
656
801
  <span class='ivar'>@error_count</span>
@@ -688,12 +833,12 @@
688
833
  <pre class="lines">
689
834
 
690
835
 
691
- 7
692
- 8
693
- 9</pre>
836
+ 52
837
+ 53
838
+ 54</pre>
694
839
  </td>
695
840
  <td>
696
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
841
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
697
842
 
698
843
  <span class='kw'>def</span> <span class='id identifier rubyid_error_interval'>error_interval</span>
699
844
  <span class='ivar'>@error_interval</span>
@@ -731,12 +876,12 @@
731
876
  <pre class="lines">
732
877
 
733
878
 
734
- 7
735
- 8
736
- 9</pre>
879
+ 52
880
+ 53
881
+ 54</pre>
737
882
  </td>
738
883
  <td>
739
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
884
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
740
885
 
741
886
  <span class='kw'>def</span> <span class='id identifier rubyid_error_limit'>error_limit</span>
742
887
  <span class='ivar'>@error_limit</span>
@@ -774,12 +919,12 @@
774
919
  <pre class="lines">
775
920
 
776
921
 
777
- 7
778
- 8
779
- 9</pre>
922
+ 52
923
+ 53
924
+ 54</pre>
780
925
  </td>
781
926
  <td>
782
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
927
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
783
928
 
784
929
  <span class='kw'>def</span> <span class='id identifier rubyid_events_exchange'>events_exchange</span>
785
930
  <span class='ivar'>@events_exchange</span>
@@ -817,12 +962,12 @@
817
962
  <pre class="lines">
818
963
 
819
964
 
820
- 7
821
- 8
822
- 9</pre>
965
+ 52
966
+ 53
967
+ 54</pre>
823
968
  </td>
824
969
  <td>
825
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
970
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
826
971
 
827
972
  <span class='kw'>def</span> <span class='id identifier rubyid_models_exchange'>models_exchange</span>
828
973
  <span class='ivar'>@models_exchange</span>
@@ -860,12 +1005,12 @@
860
1005
  <pre class="lines">
861
1006
 
862
1007
 
863
- 7
864
- 8
865
- 9</pre>
1008
+ 52
1009
+ 53
1010
+ 54</pre>
866
1011
  </td>
867
1012
  <td>
868
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
1013
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
869
1014
 
870
1015
  <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
871
1016
  <span class='ivar'>@name</span>
@@ -903,12 +1048,12 @@
903
1048
  <pre class="lines">
904
1049
 
905
1050
 
906
- 7
907
- 8
908
- 9</pre>
1051
+ 52
1052
+ 53
1053
+ 54</pre>
909
1054
  </td>
910
1055
  <td>
911
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
1056
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
912
1057
 
913
1058
  <span class='kw'>def</span> <span class='id identifier rubyid_queues'>queues</span>
914
1059
  <span class='ivar'>@queues</span>
@@ -946,12 +1091,12 @@
946
1091
  <pre class="lines">
947
1092
 
948
1093
 
949
- 7
950
- 8
951
- 9</pre>
1094
+ 52
1095
+ 53
1096
+ 54</pre>
952
1097
  </td>
953
1098
  <td>
954
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 7</span>
1099
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 52</span>
955
1100
 
956
1101
  <span class='kw'>def</span> <span class='id identifier rubyid_running'>running</span>
957
1102
  <span class='ivar'>@running</span>
@@ -969,9 +1114,9 @@
969
1114
 
970
1115
 
971
1116
  <div class="method_details first">
972
- <h3 class="signature first" id="bind_queues-instance_method">
1117
+ <h3 class="signature first" id="bind_event_queues-instance_method">
973
1118
 
974
- - (<tt>Object</tt>) <strong>bind_queues</strong>
1119
+ - (<tt>Object</tt>) <strong>bind_event_queues</strong>
975
1120
 
976
1121
 
977
1122
 
@@ -980,7 +1125,8 @@
980
1125
  </h3><div class="docstring">
981
1126
  <div class="discussion">
982
1127
 
983
- <p>Override this method to set up message observers</p>
1128
+ <p>Hook for setting up custom queues in your application. Override in your
1129
+ subclass.</p>
984
1130
 
985
1131
 
986
1132
  </div>
@@ -994,23 +1140,13 @@
994
1140
  <pre class="lines">
995
1141
 
996
1142
 
997
- 61
998
- 62
999
- 63
1000
- 64
1001
- 65
1002
- 66
1003
- 67</pre>
1143
+ 111
1144
+ 112</pre>
1004
1145
  </td>
1005
1146
  <td>
1006
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 61</span>
1147
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 111</span>
1007
1148
 
1008
- <span class='kw'>def</span> <span class='id identifier rubyid_bind_queues'>bind_queues</span>
1009
- <span class='const'>EventObserver</span><span class='period'>.</span><span class='id identifier rubyid_observed_models'>observed_models</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_model_class'>model_class</span><span class='op'>|</span>
1010
- <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find_active_observers'>find_active_observers</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_model'>model</span><span class='op'>|</span>
1011
- <span class='id identifier rubyid_register_observer'>register_observer</span><span class='lparen'>(</span><span class='id identifier rubyid_model'>model</span><span class='rparen'>)</span>
1012
- <span class='kw'>end</span>
1013
- <span class='kw'>end</span>
1149
+ <span class='kw'>def</span> <span class='id identifier rubyid_bind_event_queues'>bind_event_queues</span>
1014
1150
  <span class='kw'>end</span></pre>
1015
1151
  </td>
1016
1152
  </tr>
@@ -1018,9 +1154,9 @@
1018
1154
  </div>
1019
1155
 
1020
1156
  <div class="method_details ">
1021
- <h3 class="signature " id="has_observer?-instance_method">
1157
+ <h3 class="signature " id="run-instance_method">
1022
1158
 
1023
- - (<tt>Boolean</tt>) <strong>has_observer?</strong>(observer)
1159
+ - (<tt>Object</tt>) <strong>run</strong>
1024
1160
 
1025
1161
 
1026
1162
 
@@ -1029,24 +1165,14 @@
1029
1165
  </h3><div class="docstring">
1030
1166
  <div class="discussion">
1031
1167
 
1168
+ <p>Run the daemon process. This creates the event, error counter, and shutdown
1169
+ threads</p>
1170
+
1032
1171
 
1033
1172
  </div>
1034
1173
  </div>
1035
1174
  <div class="tags">
1036
1175
 
1037
- <p class="tag_title">Returns:</p>
1038
- <ul class="return">
1039
-
1040
- <li>
1041
-
1042
-
1043
- <span class='type'>(<tt>Boolean</tt>)</span>
1044
-
1045
-
1046
-
1047
- </li>
1048
-
1049
- </ul>
1050
1176
 
1051
1177
  </div><table class="source_code">
1052
1178
  <tr>
@@ -1054,153 +1180,45 @@
1054
1180
  <pre class="lines">
1055
1181
 
1056
1182
 
1057
- 69
1058
- 70
1059
- 71</pre>
1183
+ 93
1184
+ 94
1185
+ 95
1186
+ 96
1187
+ 97
1188
+ 98
1189
+ 99
1190
+ 100
1191
+ 101
1192
+ 102
1193
+ 103
1194
+ 104
1195
+ 105
1196
+ 106
1197
+ 107
1198
+ 108</pre>
1060
1199
  </td>
1061
1200
  <td>
1062
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 69</span>
1063
-
1064
- <span class='kw'>def</span> <span class='id identifier rubyid_has_observer?'>has_observer?</span><span class='lparen'>(</span><span class='id identifier rubyid_observer'>observer</span><span class='rparen'>)</span>
1065
- <span class='ivar'>@observers</span><span class='period'>.</span><span class='id identifier rubyid_has_key?'>has_key?</span><span class='lparen'>(</span><span class='id identifier rubyid_observer_key_for'>observer_key_for</span><span class='lparen'>(</span><span class='id identifier rubyid_observer'>observer</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='comma'>,</span> <span class='id identifier rubyid_observer'>observer</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span><span class='rparen'>)</span>
1066
- <span class='kw'>end</span></pre>
1067
- </td>
1068
- </tr>
1069
- </table>
1070
- </div>
1071
-
1072
- <div class="method_details ">
1073
- <h3 class="signature " id="max_errors-instance_method">
1074
-
1075
- - (<tt>Object</tt>) <strong>max_errors</strong>
1076
-
1077
-
1078
-
1079
-
1080
-
1081
- </h3><table class="source_code">
1082
- <tr>
1083
- <td>
1084
- <pre class="lines">
1085
-
1086
-
1087
- 37
1088
- 38
1089
- 39</pre>
1090
- </td>
1091
- <td>
1092
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 37</span>
1093
-
1094
- <span class='kw'>def</span> <span class='id identifier rubyid_max_errors'>max_errors</span>
1095
- <span class='const'>Isimud</span><span class='period'>.</span><span class='id identifier rubyid_listener_error_limit'>listener_error_limit</span> <span class='op'>||</span> <span class='const'>DEFAULT_ERROR_LIMIT</span>
1096
- <span class='kw'>end</span></pre>
1097
- </td>
1098
- </tr>
1099
- </table>
1100
- </div>
1101
-
1102
- <div class="method_details ">
1103
- <h3 class="signature " id="run-instance_method">
1104
-
1105
- - (<tt>Object</tt>) <strong>run</strong>
1106
-
1107
-
1108
-
1109
-
1110
-
1111
- </h3><table class="source_code">
1112
- <tr>
1113
- <td>
1114
- <pre class="lines">
1115
-
1116
-
1117
- 45
1118
- 46
1119
- 47
1120
- 48
1121
- 49
1122
- 50
1123
- 51
1124
- 52
1125
- 53
1126
- 54
1127
- 55
1128
- 56
1129
- 57
1130
- 58</pre>
1131
- </td>
1132
- <td>
1133
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 45</span>
1201
+ <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 93</span>
1134
1202
 
1135
1203
  <span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
1136
1204
  <span class='ivar'>@running</span> <span class='op'>=</span> <span class='kw'>true</span>
1137
1205
  <span class='id identifier rubyid_bind_queues'>bind_queues</span> <span class='kw'>and</span> <span class='kw'>return</span> <span class='kw'>if</span> <span class='id identifier rubyid_test_env?'>test_env?</span>
1138
1206
  <span class='id identifier rubyid_start_shutdown_thread'>start_shutdown_thread</span>
1139
1207
  <span class='id identifier rubyid_start_error_counter_thread'>start_error_counter_thread</span>
1208
+ <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_on_exception'>on_exception</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_e'>e</span><span class='op'>|</span>
1209
+ <span class='id identifier rubyid_count_error'>count_error</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
1210
+ <span class='kw'>end</span>
1140
1211
  <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_connect'>connect</span>
1141
- <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_exception_handler'>exception_handler</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:count_error</span><span class='rparen'>)</span><span class='rparen'>)</span>
1142
1212
  <span class='id identifier rubyid_start_event_thread'>start_event_thread</span>
1143
1213
 
1144
1214
  <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>EventListener started. Hit Ctrl-C to exit</span><span class='tstring_end'>&#39;</span></span>
1145
1215
  <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_stop'>stop</span>
1146
- <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Exiting.</span><span class='tstring_end'>&#39;</span></span>
1216
+ <span class='id identifier rubyid_puts'>puts</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Main thread wakeup - exiting.</span><span class='tstring_end'>&#39;</span></span>
1147
1217
  <span class='id identifier rubyid_client'>client</span><span class='period'>.</span><span class='id identifier rubyid_close'>close</span>
1148
1218
  <span class='kw'>end</span></pre>
1149
1219
  </td>
1150
1220
  </tr>
1151
1221
  </table>
1152
- </div>
1153
-
1154
- <div class="method_details ">
1155
- <h3 class="signature " id="test_env?-instance_method">
1156
-
1157
- - (<tt>Boolean</tt>) <strong>test_env?</strong>
1158
-
1159
-
1160
-
1161
-
1162
-
1163
- </h3><div class="docstring">
1164
- <div class="discussion">
1165
-
1166
-
1167
- </div>
1168
- </div>
1169
- <div class="tags">
1170
-
1171
- <p class="tag_title">Returns:</p>
1172
- <ul class="return">
1173
-
1174
- <li>
1175
-
1176
-
1177
- <span class='type'>(<tt>Boolean</tt>)</span>
1178
-
1179
-
1180
-
1181
- </li>
1182
-
1183
- </ul>
1184
-
1185
- </div><table class="source_code">
1186
- <tr>
1187
- <td>
1188
- <pre class="lines">
1189
-
1190
-
1191
- 41
1192
- 42
1193
- 43</pre>
1194
- </td>
1195
- <td>
1196
- <pre class="code"><span class="info file"># File 'lib/isimud/event_listener.rb', line 41</span>
1197
-
1198
- <span class='kw'>def</span> <span class='id identifier rubyid_test_env?'>test_env?</span>
1199
- <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>cucumber</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>test</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
1200
- <span class='kw'>end</span></pre>
1201
- </td>
1202
- </tr>
1203
- </table>
1204
1222
  </div>
1205
1223
 
1206
1224
  </div>
@@ -1208,9 +1226,9 @@
1208
1226
  </div>
1209
1227
 
1210
1228
  <div id="footer">
1211
- Generated on Fri Apr 3 09:28:09 2015 by
1229
+ Generated on Wed Jan 13 16:27:29 2016 by
1212
1230
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1213
- 0.8.7.6 (ruby-2.2.1).
1231
+ 0.8.7.6 (ruby-2.2.3).
1214
1232
  </div>
1215
1233
 
1216
1234
  </body>