euston-daemons 1.0.5 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Gemfile +4 -1
  2. data/Rakefile +2 -3
  3. data/euston-daemons.gemspec +50 -39
  4. data/lib/euston-daemons.rb +14 -1
  5. data/lib/euston-daemons/euston/daemon.rb +99 -0
  6. data/lib/euston-daemons/euston/daemon_component.rb +25 -0
  7. data/lib/euston-daemons/euston/daemon_component_host.rb +66 -0
  8. data/lib/euston-daemons/euston/daemon_environment.rb +59 -0
  9. data/lib/euston-daemons/euston/exceptions.rb +9 -0
  10. data/lib/euston-daemons/euston/stopwatch.rb +15 -0
  11. data/lib/euston-daemons/pipeline/config/environment.rb +78 -0
  12. data/lib/euston-daemons/pipeline/lib/command_logger/component.rb +54 -0
  13. data/lib/euston-daemons/pipeline/lib/command_logger/log.rb +31 -0
  14. data/lib/euston-daemons/pipeline/lib/command_processor/component.rb +50 -0
  15. data/lib/euston-daemons/pipeline/lib/command_processor/default_commands/retry_failed_message.rb +13 -0
  16. data/lib/euston-daemons/pipeline/lib/command_processor/default_handlers/retry_failed_message.rb +34 -0
  17. data/lib/euston-daemons/pipeline/lib/command_processor/failed_message.rb +36 -0
  18. data/lib/euston-daemons/pipeline/lib/daemon.rb +85 -0
  19. data/lib/euston-daemons/pipeline/lib/event_processor/component.rb +67 -0
  20. data/lib/euston-daemons/pipeline/lib/event_processor/default_handlers/message_failure.rb +30 -0
  21. data/lib/euston-daemons/pipeline/lib/event_store_dispatcher/component.rb +68 -0
  22. data/lib/euston-daemons/pipeline/lib/message_buffer/buffer.rb +85 -0
  23. data/lib/euston-daemons/pipeline/lib/message_buffer/component.rb +59 -0
  24. data/lib/euston-daemons/pipeline/lib/snapshotter/component.rb +48 -0
  25. data/lib/euston-daemons/pipeline/rake_task.rb +49 -0
  26. data/lib/euston-daemons/rake_task.rb +63 -66
  27. data/lib/euston-daemons/rake_tasks.rb +3 -5
  28. data/lib/euston-daemons/version.rb +1 -1
  29. data/spec/daemons/command_processor_spec.rb +48 -0
  30. data/spec/daemons/event_processor_spec.rb +55 -0
  31. data/spec/daemons/message_buffer_spec.rb +106 -0
  32. data/spec/daemons/snapshotter_spec.rb +96 -0
  33. data/spec/spec_helper.rb +91 -0
  34. data/spec/support/factories/commands.rb +16 -0
  35. data/spec/support/factories/commit.rb +7 -0
  36. data/spec/support/factories/event_message.rb +12 -0
  37. data/spec/support/factories/events.rb +8 -0
  38. data/spec/support/filters.rb +13 -0
  39. data/spec/support/sample_model/commands.rb +14 -0
  40. data/spec/support/sample_model/counter.rb +36 -0
  41. data/spec/support/sample_model/counter2.rb +46 -0
  42. data/spec/support/stub_retrying_subscription.rb +9 -0
  43. metadata +131 -67
  44. data/lib/euston-daemons/command_processor_daemon/config/environment.rb +0 -25
  45. data/lib/euston-daemons/command_processor_daemon/lib/components/command_handler_component.rb +0 -56
  46. data/lib/euston-daemons/command_processor_daemon/lib/daemon.rb +0 -43
  47. data/lib/euston-daemons/command_processor_daemon/lib/settings.rb +0 -22
  48. data/lib/euston-daemons/command_processor_daemon/rake_task.rb +0 -34
  49. data/lib/euston-daemons/event_processor_daemon/config/environment.rb +0 -25
  50. data/lib/euston-daemons/event_processor_daemon/lib/components/event_handler_component.rb +0 -58
  51. data/lib/euston-daemons/event_processor_daemon/lib/daemon.rb +0 -71
  52. data/lib/euston-daemons/event_processor_daemon/lib/settings.rb +0 -26
  53. data/lib/euston-daemons/event_processor_daemon/rake_task.rb +0 -37
  54. data/lib/euston-daemons/framework/basic_component.rb +0 -33
  55. data/lib/euston-daemons/framework/channel_thread.rb +0 -22
  56. data/lib/euston-daemons/framework/component_shutdown.rb +0 -22
  57. data/lib/euston-daemons/framework/daemon.rb +0 -27
  58. data/lib/euston-daemons/framework/handler_bindings_component.rb +0 -56
  59. data/lib/euston-daemons/framework/queue.rb +0 -71
  60. data/lib/euston-daemons/message_buffer_daemon/config/environment.rb +0 -28
  61. data/lib/euston-daemons/message_buffer_daemon/lib/components/buffer_component.rb +0 -73
  62. data/lib/euston-daemons/message_buffer_daemon/lib/components/event_store_component.rb +0 -52
  63. data/lib/euston-daemons/message_buffer_daemon/lib/daemon.rb +0 -48
  64. data/lib/euston-daemons/message_buffer_daemon/lib/message_logger.rb +0 -54
  65. data/lib/euston-daemons/message_buffer_daemon/lib/publisher.rb +0 -56
  66. data/lib/euston-daemons/message_buffer_daemon/lib/read_model/message_log.rb +0 -36
  67. data/lib/euston-daemons/message_buffer_daemon/lib/settings.rb +0 -14
  68. data/lib/euston-daemons/message_buffer_daemon/lib/subscriber.rb +0 -60
  69. data/lib/euston-daemons/message_buffer_daemon/rake_task.rb +0 -30
@@ -0,0 +1,12 @@
1
+ class Cranky::Factory
2
+ def event_message
3
+ headers = { :id => Euston.uuid.generate,
4
+ :type => Faker::Lorem.words(2).join('_'),
5
+ :version => 1,
6
+ :timestamp => Time.now.to_f }
7
+
8
+ body = { :number => rand(9) + 1 }
9
+
10
+ Euston::EventStore::EventMessage.new 'headers' => headers, 'body' => body
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ # class Cranky::Factory
2
+ # def empty_event
3
+ # { :headers => { :id => Uuid.generate, :version => 1 }, :body => { } }
4
+ # hash = define :class => Hash,
5
+ # :id => Uuid.generate,
6
+ # :type => F
7
+ # end
8
+ # end
@@ -0,0 +1,13 @@
1
+ def initialize_amqp connection
2
+ @channel = connection.create_channel
3
+ end
4
+
5
+ def initialize_rabbitmq config
6
+ @rabbitmqadmin = RabbitMqAdminCli.new
7
+ @rabbitmqadmin.initialize_vhost config[:virtual_host]
8
+ @rabbitmqadmin.initialize_user config[:virtual_host], config[:username], config[:password]
9
+ end
10
+
11
+ def purge_database database
12
+ database.collections.each { |collection| collection.remove unless collection.name.downcase =~ /^system/ }
13
+ end
@@ -0,0 +1,14 @@
1
+ module Euston
2
+ module Daemons
3
+ module SampleModel
4
+ class CreateCounter < Euston::Command
5
+ validates :id, :presence => true
6
+ end
7
+
8
+ class IncrementCounter < Euston::Command
9
+ validates :counter_id, :presence => true
10
+ validates :amount, :presence => true
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,36 @@
1
+ module Euston
2
+ module Daemons
3
+ module SampleModel
4
+ class Counter
5
+ include Euston::AggregateRoot
6
+
7
+ created_by :create_counter do |command|
8
+ apply_event :counter_created, 1, command
9
+ end
10
+
11
+ consumes :increment_counter, :id => :counter_id do |command|
12
+ apply_event :counter_incremented, 1, :count => @count + command.amount
13
+ end
14
+
15
+ applies :counter_created do |event|
16
+ @count = 0
17
+ end
18
+
19
+ applies :counter_incremented do |event|
20
+ @count = event.count
21
+ end
22
+
23
+ load_snapshot 1 do |snapshot|
24
+ @count = snapshot[:count]
25
+ @snapshot_loaded = snapshot
26
+ end
27
+
28
+ take_snapshot 1 do
29
+ { :count => @count }
30
+ end
31
+
32
+ attr_reader :count, :snapshot_loaded
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,46 @@
1
+ module Euston
2
+ module Daemons
3
+ module SampleModel
4
+ class Counter2
5
+ include Euston::AggregateRoot
6
+
7
+ created_by :create_counter do |command|
8
+ apply_event :counter_created, 1, command
9
+ end
10
+
11
+ consumes :increment_counter, :id => :counter_id do |command|
12
+ apply_event :counter_incremented, 1, :count => @count + command.amount
13
+ end
14
+
15
+ subscribes :external_thing_happened do |headers, event|
16
+ apply_event :noted_that_external_thing_happened, 1
17
+ end
18
+
19
+ applies :counter_created do |event|
20
+ @count = 0
21
+ @external_thing_happened = false
22
+ end
23
+
24
+ applies :counter_incremented do |event|
25
+ @count = event.count
26
+ end
27
+
28
+ applies :noted_that_external_thing_happened do |event|
29
+ @external_thing_happened = true
30
+ end
31
+
32
+ load_snapshot 1 do |snapshot|
33
+ @count = snapshot[:count]
34
+ @external_thing_happened = snapshot[:heard_about_external_thing]
35
+ @snapshot_loaded = snapshot
36
+ end
37
+
38
+ take_snapshot 1 do
39
+ { :count => @count, :heard_about_external_thing => @external_thing_happened }
40
+ end
41
+
42
+ attr_reader :count, :snapshot_loaded
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,9 @@
1
+ class StubRetryingSubscription
2
+ include Hollywood
3
+
4
+ def subscribe; end
5
+
6
+ def stub_message_receipt message
7
+ callback :message_received, message
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: euston-daemons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,33 +10,33 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-09-27 00:00:00.000000000 Z
13
+ date: 2011-10-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &21218820 !ruby/object:Gem::Requirement
17
+ requirement: &83378840 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ~>
20
+ - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: 3.0.0
22
+ version: 3.0.10
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *21218820
25
+ version_requirements: *83378840
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activesupport
28
- requirement: &21217900 !ruby/object:Gem::Requirement
28
+ requirement: &83378600 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
- - - ~>
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.0
33
+ version: 3.0.10
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *21217900
36
+ version_requirements: *83378600
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: erb-yaml
39
- requirement: &21217040 !ruby/object:Gem::Requirement
39
+ requirement: &83378370 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,43 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *21217040
47
+ version_requirements: *83378370
48
+ - !ruby/object:Gem::Dependency
49
+ name: euston
50
+ requirement: &83378140 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.2.0
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: *83378140
59
+ - !ruby/object:Gem::Dependency
60
+ name: euston-eventstore
61
+ requirement: &83377910 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 1.2.0
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: *83377910
70
+ - !ruby/object:Gem::Dependency
71
+ name: euston-rabbitmq
72
+ requirement: &83377680 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.0
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: *83377680
48
81
  - !ruby/object:Gem::Dependency
49
82
  name: hollywood
50
- requirement: &21216500 !ruby/object:Gem::Requirement
83
+ requirement: &83377450 !ruby/object:Gem::Requirement
51
84
  none: false
52
85
  requirements:
53
86
  - - ~>
@@ -55,32 +88,32 @@ dependencies:
55
88
  version: 1.0.0
56
89
  type: :runtime
57
90
  prerelease: false
58
- version_requirements: *21216500
91
+ version_requirements: *83377450
59
92
  - !ruby/object:Gem::Dependency
60
93
  name: i18n
61
- requirement: &21215860 !ruby/object:Gem::Requirement
94
+ requirement: &83377220 !ruby/object:Gem::Requirement
62
95
  none: false
63
96
  requirements:
64
- - - ~>
97
+ - - ! '>='
65
98
  - !ruby/object:Gem::Version
66
99
  version: 0.5.0
67
100
  type: :runtime
68
101
  prerelease: false
69
- version_requirements: *21215860
102
+ version_requirements: *83377220
70
103
  - !ruby/object:Gem::Dependency
71
- name: require_all
72
- requirement: &21215080 !ruby/object:Gem::Requirement
104
+ name: macaddr
105
+ requirement: &83376990 !ruby/object:Gem::Requirement
73
106
  none: false
74
107
  requirements:
75
108
  - - ~>
76
109
  - !ruby/object:Gem::Version
77
- version: 1.2.0
110
+ version: 1.4.0
78
111
  type: :runtime
79
112
  prerelease: false
80
- version_requirements: *21215080
113
+ version_requirements: *83376990
81
114
  - !ruby/object:Gem::Dependency
82
115
  name: safely
83
- requirement: &21214260 !ruby/object:Gem::Requirement
116
+ requirement: &83376760 !ruby/object:Gem::Requirement
84
117
  none: false
85
118
  requirements:
86
119
  - - ~>
@@ -88,43 +121,65 @@ dependencies:
88
121
  version: 0.3.0
89
122
  type: :runtime
90
123
  prerelease: false
91
- version_requirements: *21214260
124
+ version_requirements: *83376760
92
125
  - !ruby/object:Gem::Dependency
93
- name: euston
94
- requirement: &21213320 !ruby/object:Gem::Requirement
126
+ name: awesome_print
127
+ requirement: &83376520 !ruby/object:Gem::Requirement
95
128
  none: false
96
129
  requirements:
97
130
  - - ~>
98
131
  - !ruby/object:Gem::Version
99
- version: 1.0.0
100
- type: :runtime
132
+ version: 0.4.0
133
+ type: :development
101
134
  prerelease: false
102
- version_requirements: *21213320
135
+ version_requirements: *83376520
103
136
  - !ruby/object:Gem::Dependency
104
- name: euston-eventstore
105
- requirement: &21212740 !ruby/object:Gem::Requirement
137
+ name: cranky
138
+ requirement: &83376290 !ruby/object:Gem::Requirement
106
139
  none: false
107
140
  requirements:
108
141
  - - ~>
109
142
  - !ruby/object:Gem::Version
110
- version: 1.0.0
111
- type: :runtime
143
+ version: 0.2.0
144
+ type: :development
112
145
  prerelease: false
113
- version_requirements: *21212740
146
+ version_requirements: *83376290
114
147
  - !ruby/object:Gem::Dependency
115
- name: mongoid-glue
116
- requirement: &21211960 !ruby/object:Gem::Requirement
148
+ name: ffaker
149
+ requirement: &83376060 !ruby/object:Gem::Requirement
117
150
  none: false
118
151
  requirements:
119
152
  - - ~>
120
153
  - !ruby/object:Gem::Version
121
- version: 1.0.0
122
- type: :runtime
154
+ version: 1.8.0
155
+ type: :development
156
+ prerelease: false
157
+ version_requirements: *83376060
158
+ - !ruby/object:Gem::Dependency
159
+ name: fuubar
160
+ requirement: &83375830 !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 0.0.0
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: *83375830
169
+ - !ruby/object:Gem::Dependency
170
+ name: rabbitmqadmin-cli
171
+ requirement: &83375600 !ruby/object:Gem::Requirement
172
+ none: false
173
+ requirements:
174
+ - - ~>
175
+ - !ruby/object:Gem::Version
176
+ version: 1.0.2
177
+ type: :development
123
178
  prerelease: false
124
- version_requirements: *21211960
179
+ version_requirements: *83375600
125
180
  - !ruby/object:Gem::Dependency
126
181
  name: rspec
127
- requirement: &21211260 !ruby/object:Gem::Requirement
182
+ requirement: &83375370 !ruby/object:Gem::Requirement
128
183
  none: false
129
184
  requirements:
130
185
  - - ~>
@@ -132,7 +187,7 @@ dependencies:
132
187
  version: 2.6.0
133
188
  type: :development
134
189
  prerelease: false
135
- version_requirements: *21211260
190
+ version_requirements: *83375370
136
191
  description: ''
137
192
  email:
138
193
  - lee.m.henson@gmail.com
@@ -146,35 +201,44 @@ files:
146
201
  - Rakefile
147
202
  - euston-daemons.gemspec
148
203
  - lib/euston-daemons.rb
149
- - lib/euston-daemons/command_processor_daemon/config/environment.rb
150
- - lib/euston-daemons/command_processor_daemon/lib/components/command_handler_component.rb
151
- - lib/euston-daemons/command_processor_daemon/lib/daemon.rb
152
- - lib/euston-daemons/command_processor_daemon/lib/settings.rb
153
- - lib/euston-daemons/command_processor_daemon/rake_task.rb
154
- - lib/euston-daemons/event_processor_daemon/config/environment.rb
155
- - lib/euston-daemons/event_processor_daemon/lib/components/event_handler_component.rb
156
- - lib/euston-daemons/event_processor_daemon/lib/daemon.rb
157
- - lib/euston-daemons/event_processor_daemon/lib/settings.rb
158
- - lib/euston-daemons/event_processor_daemon/rake_task.rb
159
- - lib/euston-daemons/framework/basic_component.rb
160
- - lib/euston-daemons/framework/channel_thread.rb
161
- - lib/euston-daemons/framework/component_shutdown.rb
162
- - lib/euston-daemons/framework/daemon.rb
163
- - lib/euston-daemons/framework/handler_bindings_component.rb
164
- - lib/euston-daemons/framework/queue.rb
165
- - lib/euston-daemons/message_buffer_daemon/config/environment.rb
166
- - lib/euston-daemons/message_buffer_daemon/lib/components/buffer_component.rb
167
- - lib/euston-daemons/message_buffer_daemon/lib/components/event_store_component.rb
168
- - lib/euston-daemons/message_buffer_daemon/lib/daemon.rb
169
- - lib/euston-daemons/message_buffer_daemon/lib/message_logger.rb
170
- - lib/euston-daemons/message_buffer_daemon/lib/publisher.rb
171
- - lib/euston-daemons/message_buffer_daemon/lib/read_model/message_log.rb
172
- - lib/euston-daemons/message_buffer_daemon/lib/settings.rb
173
- - lib/euston-daemons/message_buffer_daemon/lib/subscriber.rb
174
- - lib/euston-daemons/message_buffer_daemon/rake_task.rb
204
+ - lib/euston-daemons/euston/daemon.rb
205
+ - lib/euston-daemons/euston/daemon_component.rb
206
+ - lib/euston-daemons/euston/daemon_component_host.rb
207
+ - lib/euston-daemons/euston/daemon_environment.rb
208
+ - lib/euston-daemons/euston/exceptions.rb
209
+ - lib/euston-daemons/euston/stopwatch.rb
210
+ - lib/euston-daemons/pipeline/config/environment.rb
211
+ - lib/euston-daemons/pipeline/lib/command_logger/component.rb
212
+ - lib/euston-daemons/pipeline/lib/command_logger/log.rb
213
+ - lib/euston-daemons/pipeline/lib/command_processor/component.rb
214
+ - lib/euston-daemons/pipeline/lib/command_processor/default_commands/retry_failed_message.rb
215
+ - lib/euston-daemons/pipeline/lib/command_processor/default_handlers/retry_failed_message.rb
216
+ - lib/euston-daemons/pipeline/lib/command_processor/failed_message.rb
217
+ - lib/euston-daemons/pipeline/lib/daemon.rb
218
+ - lib/euston-daemons/pipeline/lib/event_processor/component.rb
219
+ - lib/euston-daemons/pipeline/lib/event_processor/default_handlers/message_failure.rb
220
+ - lib/euston-daemons/pipeline/lib/event_store_dispatcher/component.rb
221
+ - lib/euston-daemons/pipeline/lib/message_buffer/buffer.rb
222
+ - lib/euston-daemons/pipeline/lib/message_buffer/component.rb
223
+ - lib/euston-daemons/pipeline/lib/snapshotter/component.rb
224
+ - lib/euston-daemons/pipeline/rake_task.rb
175
225
  - lib/euston-daemons/rake_task.rb
176
226
  - lib/euston-daemons/rake_tasks.rb
177
227
  - lib/euston-daemons/version.rb
228
+ - spec/daemons/command_processor_spec.rb
229
+ - spec/daemons/event_processor_spec.rb
230
+ - spec/daemons/message_buffer_spec.rb
231
+ - spec/daemons/snapshotter_spec.rb
232
+ - spec/spec_helper.rb
233
+ - spec/support/factories/commands.rb
234
+ - spec/support/factories/commit.rb
235
+ - spec/support/factories/event_message.rb
236
+ - spec/support/factories/events.rb
237
+ - spec/support/filters.rb
238
+ - spec/support/sample_model/commands.rb
239
+ - spec/support/sample_model/counter.rb
240
+ - spec/support/sample_model/counter2.rb
241
+ - spec/support/stub_retrying_subscription.rb
178
242
  homepage: http://github.com/leemhenson/euston-daemons
179
243
  licenses: []
180
244
  post_install_message:
@@ -195,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
259
  version: '0'
196
260
  requirements: []
197
261
  rubyforge_project:
198
- rubygems_version: 1.8.6
262
+ rubygems_version: 1.8.10
199
263
  signing_key:
200
264
  specification_version: 3
201
265
  summary: Message buffer, command processor and event processor daemons for Euston-RabbitMq