euston-daemons 1.1.0-java → 1.2.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/euston-daemons.gemspec +27 -52
- data/lib/euston-daemons/euston/daemon.rb +7 -1
- data/lib/euston-daemons/euston/daemon_component.rb +9 -49
- data/lib/euston-daemons/euston/daemon_component_host.rb +66 -0
- data/lib/euston-daemons/euston/daemon_environment.rb +10 -5
- data/lib/euston-daemons/euston/exceptions.rb +9 -0
- data/lib/euston-daemons/euston/stopwatch.rb +15 -0
- data/lib/euston-daemons/pipeline/config/environment.rb +74 -0
- data/lib/euston-daemons/pipeline/lib/command_logger/component.rb +54 -0
- data/lib/euston-daemons/pipeline/lib/command_logger/log.rb +31 -0
- data/lib/euston-daemons/pipeline/lib/command_processor/component.rb +50 -0
- data/lib/euston-daemons/pipeline/lib/command_processor/default_handlers/retry_failed_message.rb +34 -0
- data/lib/euston-daemons/pipeline/lib/command_processor/failed_message.rb +36 -0
- data/lib/euston-daemons/pipeline/lib/daemon.rb +77 -0
- data/lib/euston-daemons/pipeline/lib/event_processor/component.rb +67 -0
- data/lib/euston-daemons/pipeline/lib/event_processor/default_handlers/message_failure.rb +30 -0
- data/lib/euston-daemons/pipeline/lib/event_store_dispatcher/component.rb +68 -0
- data/lib/euston-daemons/pipeline/lib/message_buffer/buffer.rb +85 -0
- data/lib/euston-daemons/pipeline/lib/message_buffer/component.rb +59 -0
- data/lib/euston-daemons/pipeline/lib/snapshotter/component.rb +48 -0
- data/lib/euston-daemons/pipeline/rake_task.rb +45 -0
- data/lib/euston-daemons/rake_task.rb +40 -19
- data/lib/euston-daemons/rake_tasks.rb +1 -3
- data/lib/euston-daemons/version.rb +1 -1
- data/lib/euston-daemons.rb +3 -1
- data/spec/daemons/{command_handler_spec.rb → command_processor_spec.rb} +3 -3
- data/spec/daemons/{event_handler_spec.rb → event_processor_spec.rb} +2 -2
- data/spec/daemons/{command_buffer_publisher_spec.rb → message_buffer_spec.rb} +19 -23
- data/spec/daemons/{snapshot_client_spec.rb → snapshotter_spec.rb} +3 -5
- data/spec/spec_helper.rb +23 -9
- data/spec/support/filters.rb +4 -5
- metadata +73 -88
- data/lib/euston-daemons/command_processor_daemon/config/environment.rb +0 -34
- data/lib/euston-daemons/command_processor_daemon/lib/clients/command_handler.rb +0 -37
- data/lib/euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message.rb +0 -35
- data/lib/euston-daemons/command_processor_daemon/lib/daemon.rb +0 -22
- data/lib/euston-daemons/command_processor_daemon/lib/mongo_models/failed_message.rb +0 -34
- data/lib/euston-daemons/command_processor_daemon/rake_task.rb +0 -36
- data/lib/euston-daemons/euston/daemon_client.rb +0 -24
- data/lib/euston-daemons/event_processor_daemon/config/environment.rb +0 -36
- data/lib/euston-daemons/event_processor_daemon/lib/clients/event_handler.rb +0 -42
- data/lib/euston-daemons/event_processor_daemon/lib/daemon.rb +0 -24
- data/lib/euston-daemons/event_processor_daemon/lib/event_handlers/message_failure.rb +0 -27
- data/lib/euston-daemons/event_processor_daemon/rake_task.rb +0 -39
- data/lib/euston-daemons/message_buffer_daemon/config/environment.rb +0 -42
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_cleanup.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_publisher.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_logger.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/euston_exchange_accessors.rb +0 -15
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_cleanup.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_publisher.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_logger.rb +0 -9
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_store_dispatcher.rb +0 -25
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_cleanup.rb +0 -52
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_publisher.rb +0 -37
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_logger.rb +0 -45
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/mongo_model_accessors.rb +0 -21
- data/lib/euston-daemons/message_buffer_daemon/lib/daemon.rb +0 -17
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_buffer.rb +0 -11
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_log.rb +0 -11
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_buffer.rb +0 -11
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_log.rb +0 -11
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_buffer.rb +0 -57
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_log.rb +0 -29
- data/lib/euston-daemons/message_buffer_daemon/rake_task.rb +0 -32
- data/lib/euston-daemons/snapshot_daemon/lib/clients/snapshotter.rb +0 -43
- data/sample/Rakefile +0 -63
- data/sample/amqp_config.yml +0 -14
- data/sample/command_handlers.rb +0 -17
- data/sample/command_processor_daemon_config.yml +0 -9
- data/sample/event_handlers.rb +0 -21
- data/sample/event_processor_daemon_config.yml +0 -8
- data/sample/message_buffer_daemon_config.yml +0 -8
- data/sample/mongoid_config.yml +0 -13
- data/sample/pids/.placeholder +0 -0
@@ -1,10 +1,6 @@
|
|
1
|
-
describe '
|
2
|
-
require 'euston-daemons/
|
3
|
-
require 'euston-daemons/
|
4
|
-
require 'euston-daemons/message_buffer_daemon/lib/clients/message_buffer_publisher'
|
5
|
-
require 'euston-daemons/message_buffer_daemon/lib/clients/command_buffer_publisher'
|
6
|
-
require 'euston-daemons/message_buffer_daemon/lib/mongo_models/message_buffer'
|
7
|
-
require 'euston-daemons/message_buffer_daemon/lib/mongo_models/command_buffer'
|
1
|
+
describe 'message buffer component', :purge_event_store do
|
2
|
+
require 'euston-daemons/pipeline/lib/message_buffer/buffer'
|
3
|
+
require 'euston-daemons/pipeline/lib/message_buffer/component'
|
8
4
|
|
9
5
|
let(:logger) { Euston::NullLogger.instance }
|
10
6
|
let(:channel) { double('channel').as_null_object }
|
@@ -12,8 +8,8 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
12
8
|
let(:exchange) { double('exchange').as_null_object }
|
13
9
|
let(:published) { [] }
|
14
10
|
let(:collection) { @event_store_database[buffer.name] }
|
15
|
-
let(:buffer) { Euston::
|
16
|
-
let(:
|
11
|
+
let(:buffer) { Euston::Daemons::Pipeline::MessageBuffer::Buffer.new @event_store_database }
|
12
|
+
let(:component) { Euston::Daemons::Pipeline::MessageBuffer::Component.new channel }
|
17
13
|
|
18
14
|
module Euston
|
19
15
|
class DaemonEnvironment
|
@@ -36,8 +32,8 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
36
32
|
it { should == 0 }
|
37
33
|
end
|
38
34
|
|
39
|
-
context 'the
|
40
|
-
before {
|
35
|
+
context 'the component runs' do
|
36
|
+
before { component.run }
|
41
37
|
|
42
38
|
describe 'published commands' do
|
43
39
|
subject { published }
|
@@ -49,7 +45,7 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
49
45
|
context 'there is a due command' do
|
50
46
|
|
51
47
|
before do
|
52
|
-
buffer.
|
48
|
+
buffer.enqueue :commands, command
|
53
49
|
end
|
54
50
|
|
55
51
|
describe 'command buffer size' do
|
@@ -57,8 +53,8 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
57
53
|
it { should == 1 }
|
58
54
|
end
|
59
55
|
|
60
|
-
context 'the
|
61
|
-
before {
|
56
|
+
context 'the component runs' do
|
57
|
+
before { component.run }
|
62
58
|
|
63
59
|
describe 'published commands' do
|
64
60
|
subject { published }
|
@@ -71,20 +67,20 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
71
67
|
end
|
72
68
|
|
73
69
|
describe 'buffered command' do
|
74
|
-
subject
|
75
|
-
|
70
|
+
subject { collection.count }
|
71
|
+
it { should == 0 }
|
76
72
|
end
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
80
76
|
context 'there is a command that is not yet due' do
|
81
77
|
before do
|
82
|
-
buffer.
|
83
|
-
collection.update({}, { '$set' => { '
|
78
|
+
buffer.enqueue :commands, command
|
79
|
+
collection.update({}, { '$set' => { 'dispatch_at' => Time.now.to_f + 1000 } }, { :safe => true })
|
84
80
|
end
|
85
81
|
|
86
|
-
context 'the
|
87
|
-
before {
|
82
|
+
context 'the component runs' do
|
83
|
+
before { component.run }
|
88
84
|
|
89
85
|
describe 'published commands' do
|
90
86
|
subject { published }
|
@@ -95,11 +91,11 @@ describe 'command buffer publisher client', :purge_event_store do
|
|
95
91
|
|
96
92
|
context 'a command is buffered for dispatch in the future' do
|
97
93
|
before do
|
98
|
-
buffer.
|
94
|
+
buffer.enqueue :commands, command, Time.now.to_f + 1000
|
99
95
|
end
|
100
96
|
|
101
|
-
context 'the
|
102
|
-
before {
|
97
|
+
context 'the component runs' do
|
98
|
+
before { component.run }
|
103
99
|
|
104
100
|
describe 'published commands' do
|
105
101
|
subject { published }
|
@@ -1,9 +1,9 @@
|
|
1
|
-
describe '
|
2
|
-
require 'euston-daemons/
|
1
|
+
describe 'snapshotter component', :purge_event_store, :euston_event_store do
|
2
|
+
require 'euston-daemons/pipeline/lib/snapshotter/component'
|
3
3
|
|
4
4
|
let(:logger) { Euston::NullLogger.instance }
|
5
5
|
let(:threshold) { 2 }
|
6
|
-
let(:snapshotter) { Euston::
|
6
|
+
let(:snapshotter) { Euston::Daemons::Pipeline::Snapshotter::Component.new @event_store, threshold, logger }
|
7
7
|
let(:commands) { [] }
|
8
8
|
let(:counter_id) { Uuid.generate }
|
9
9
|
|
@@ -55,8 +55,6 @@ describe 'snapshot client', :purge_event_store, :euston_event_store do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'multiple snapshots taken over time' do
|
58
|
-
# let(:logger) { Logger.new(STDOUT) }
|
59
|
-
|
60
58
|
let(:commands) { [ Factory.build(:create_counter_command, :id => counter_id),
|
61
59
|
Factory.build(:increment_counter_command, :counter_id => counter_id, :amount => 1),
|
62
60
|
Factory.build(:increment_counter_command, :counter_id => counter_id, :amount => 2) ] }
|
data/spec/spec_helper.rb
CHANGED
@@ -10,6 +10,7 @@ require 'cranky'
|
|
10
10
|
require 'ffaker'
|
11
11
|
require 'mongo' unless jruby
|
12
12
|
require 'jmongo' if jruby
|
13
|
+
require 'hot_bunnies' if jruby
|
13
14
|
require 'safely'
|
14
15
|
|
15
16
|
specs_path = File.dirname __FILE__
|
@@ -26,18 +27,21 @@ Safely.configure do |config|
|
|
26
27
|
config.strategies = [ Safely::Strategy::Log ]
|
27
28
|
end
|
28
29
|
|
29
|
-
amqp_config = { :host => 'localhost',
|
30
|
+
amqp_config = { :host => 'localhost',
|
31
|
+
:virtual_host => 'euston-daemons-test',
|
32
|
+
:username => 'euston-daemons-test-user',
|
33
|
+
:password => 'password' }
|
30
34
|
|
31
|
-
mongo_connection
|
32
|
-
event_store_database
|
33
|
-
|
35
|
+
mongo_connection = Mongo::Connection.from_uri 'mongodb://0.0.0.0:27017/?safe=true;fsync=true;autoconnectretry=true;w=1;'
|
36
|
+
event_store_database = Mongo::DB.new 'euston-daemons-test-event-store', mongo_connection
|
37
|
+
projections_database = Mongo::DB.new 'euston-daemons-test-projections', mongo_connection
|
34
38
|
|
35
39
|
RSpec.configure do |config|
|
36
40
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
37
41
|
|
38
42
|
config.before(:each) do
|
39
43
|
@event_store_database = event_store_database
|
40
|
-
@
|
44
|
+
@projections_database = projections_database
|
41
45
|
end
|
42
46
|
|
43
47
|
config.before(:each, :euston_event_store) do
|
@@ -63,15 +67,25 @@ RSpec.configure do |config|
|
|
63
67
|
|
64
68
|
config.before(:each, :purge_mongo) do
|
65
69
|
purge_database event_store_database
|
66
|
-
purge_database
|
70
|
+
purge_database projections_database
|
67
71
|
end
|
68
72
|
|
69
73
|
config.before(:each, :purge_rabbitmq) do
|
70
74
|
initialize_rabbitmq amqp_config
|
71
|
-
initialize_amqp amqp_config
|
72
75
|
end
|
73
76
|
|
74
|
-
config.before(:
|
75
|
-
|
77
|
+
config.before(:all, :purge_rabbitmq) do
|
78
|
+
@amqp_connection = HotBunnies.connect amqp_config
|
79
|
+
|
80
|
+
initialize_amqp @amqp_connection
|
81
|
+
end
|
82
|
+
|
83
|
+
config.before(:each, :purge_projections) do
|
84
|
+
purge_database projections_database
|
85
|
+
end
|
86
|
+
|
87
|
+
config.after(:all, :purge_rabbitmq) do
|
88
|
+
@channel.close
|
89
|
+
@amqp_connection.close
|
76
90
|
end
|
77
91
|
end
|
data/spec/support/filters.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
def initialize_amqp
|
2
|
-
|
3
|
-
@channel = AMQP::Channel.new
|
1
|
+
def initialize_amqp connection
|
2
|
+
@channel = connection.create_channel
|
4
3
|
end
|
5
4
|
|
6
5
|
def initialize_rabbitmq config
|
7
6
|
@rabbitmqadmin = RabbitMqAdminCli.new
|
8
|
-
@rabbitmqadmin.initialize_vhost config[:
|
9
|
-
@rabbitmqadmin.initialize_user config[:
|
7
|
+
@rabbitmqadmin.initialize_vhost config[:virtual_host]
|
8
|
+
@rabbitmqadmin.initialize_user config[:virtual_host], config[:username], config[:password]
|
10
9
|
end
|
11
10
|
|
12
11
|
def purge_database database
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: euston-daemons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.2.0
|
6
6
|
platform: java
|
7
7
|
authors:
|
8
8
|
- Lee Henson
|
@@ -10,194 +10,205 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-12 00:00:00.000000000 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activemodel
|
18
|
-
version_requirements: &
|
18
|
+
version_requirements: &2216 !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 3.0.0
|
23
23
|
none: false
|
24
|
-
requirement: *
|
24
|
+
requirement: *2216
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
|
-
version_requirements: &
|
29
|
+
version_requirements: &2234 !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 3.0.0
|
34
34
|
none: false
|
35
|
-
requirement: *
|
35
|
+
requirement: *2234
|
36
36
|
prerelease: false
|
37
37
|
type: :runtime
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: erb-yaml
|
40
|
-
version_requirements: &
|
40
|
+
version_requirements: &2250 !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: 1.0.0
|
45
45
|
none: false
|
46
|
-
requirement: *
|
46
|
+
requirement: *2250
|
47
47
|
prerelease: false
|
48
48
|
type: :runtime
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: euston
|
51
|
-
version_requirements: &
|
51
|
+
version_requirements: &2266 !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.
|
55
|
+
version: 1.2.0
|
56
56
|
none: false
|
57
|
-
requirement: *
|
57
|
+
requirement: *2266
|
58
58
|
prerelease: false
|
59
59
|
type: :runtime
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: euston-eventstore
|
62
|
-
version_requirements: &
|
62
|
+
version_requirements: &2282 !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - ~>
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: 1.
|
66
|
+
version: 1.2.0
|
67
67
|
none: false
|
68
|
-
requirement: *
|
68
|
+
requirement: *2282
|
69
69
|
prerelease: false
|
70
70
|
type: :runtime
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: euston-rabbitmq
|
73
|
-
version_requirements: &
|
73
|
+
version_requirements: &2298 !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: 1.
|
77
|
+
version: 1.2.0
|
78
78
|
none: false
|
79
|
-
requirement: *
|
79
|
+
requirement: *2298
|
80
80
|
prerelease: false
|
81
81
|
type: :runtime
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: hollywood
|
84
|
-
version_requirements: &
|
84
|
+
version_requirements: &2314 !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - ~>
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 1.0.0
|
89
89
|
none: false
|
90
|
-
requirement: *
|
90
|
+
requirement: *2314
|
91
91
|
prerelease: false
|
92
92
|
type: :runtime
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: i18n
|
95
|
-
version_requirements: &
|
95
|
+
version_requirements: &2330 !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
97
|
- - ~>
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: 0.5.0
|
100
100
|
none: false
|
101
|
-
requirement: *
|
101
|
+
requirement: *2330
|
102
|
+
prerelease: false
|
103
|
+
type: :runtime
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: macaddr
|
106
|
+
version_requirements: &2346 !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.4.0
|
111
|
+
none: false
|
112
|
+
requirement: *2346
|
102
113
|
prerelease: false
|
103
114
|
type: :runtime
|
104
115
|
- !ruby/object:Gem::Dependency
|
105
116
|
name: safely
|
106
|
-
version_requirements: &
|
117
|
+
version_requirements: &2362 !ruby/object:Gem::Requirement
|
107
118
|
requirements:
|
108
119
|
- - ~>
|
109
120
|
- !ruby/object:Gem::Version
|
110
121
|
version: 0.3.0
|
111
122
|
none: false
|
112
|
-
requirement: *
|
123
|
+
requirement: *2362
|
113
124
|
prerelease: false
|
114
125
|
type: :runtime
|
115
126
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
117
|
-
version_requirements: &
|
127
|
+
name: hot_bunnies
|
128
|
+
version_requirements: &2378 !ruby/object:Gem::Requirement
|
118
129
|
requirements:
|
119
130
|
- - ~>
|
120
131
|
- !ruby/object:Gem::Version
|
121
|
-
version: 1.0.
|
132
|
+
version: 1.3.0.pre1
|
122
133
|
none: false
|
123
|
-
requirement: *
|
134
|
+
requirement: *2378
|
124
135
|
prerelease: false
|
125
136
|
type: :runtime
|
126
137
|
- !ruby/object:Gem::Dependency
|
127
138
|
name: jmongo
|
128
|
-
version_requirements: &
|
139
|
+
version_requirements: &2394 !ruby/object:Gem::Requirement
|
129
140
|
requirements:
|
130
141
|
- - ~>
|
131
142
|
- !ruby/object:Gem::Version
|
132
143
|
version: 1.1.0
|
133
144
|
none: false
|
134
|
-
requirement: *
|
145
|
+
requirement: *2394
|
135
146
|
prerelease: false
|
136
147
|
type: :runtime
|
137
148
|
- !ruby/object:Gem::Dependency
|
138
149
|
name: awesome_print
|
139
|
-
version_requirements: &
|
150
|
+
version_requirements: &2410 !ruby/object:Gem::Requirement
|
140
151
|
requirements:
|
141
152
|
- - ~>
|
142
153
|
- !ruby/object:Gem::Version
|
143
154
|
version: 0.4.0
|
144
155
|
none: false
|
145
|
-
requirement: *
|
156
|
+
requirement: *2410
|
146
157
|
prerelease: false
|
147
158
|
type: :development
|
148
159
|
- !ruby/object:Gem::Dependency
|
149
160
|
name: cranky
|
150
|
-
version_requirements: &
|
161
|
+
version_requirements: &2428 !ruby/object:Gem::Requirement
|
151
162
|
requirements:
|
152
163
|
- - ~>
|
153
164
|
- !ruby/object:Gem::Version
|
154
165
|
version: 0.2.0
|
155
166
|
none: false
|
156
|
-
requirement: *
|
167
|
+
requirement: *2428
|
157
168
|
prerelease: false
|
158
169
|
type: :development
|
159
170
|
- !ruby/object:Gem::Dependency
|
160
171
|
name: ffaker
|
161
|
-
version_requirements: &
|
172
|
+
version_requirements: &2444 !ruby/object:Gem::Requirement
|
162
173
|
requirements:
|
163
174
|
- - ~>
|
164
175
|
- !ruby/object:Gem::Version
|
165
176
|
version: 1.8.0
|
166
177
|
none: false
|
167
|
-
requirement: *
|
178
|
+
requirement: *2444
|
168
179
|
prerelease: false
|
169
180
|
type: :development
|
170
181
|
- !ruby/object:Gem::Dependency
|
171
182
|
name: fuubar
|
172
|
-
version_requirements: &
|
183
|
+
version_requirements: &2460 !ruby/object:Gem::Requirement
|
173
184
|
requirements:
|
174
185
|
- - ~>
|
175
186
|
- !ruby/object:Gem::Version
|
176
187
|
version: 0.0.0
|
177
188
|
none: false
|
178
|
-
requirement: *
|
189
|
+
requirement: *2460
|
179
190
|
prerelease: false
|
180
191
|
type: :development
|
181
192
|
- !ruby/object:Gem::Dependency
|
182
193
|
name: rabbitmqadmin-cli
|
183
|
-
version_requirements: &
|
194
|
+
version_requirements: &2476 !ruby/object:Gem::Requirement
|
184
195
|
requirements:
|
185
196
|
- - ~>
|
186
197
|
- !ruby/object:Gem::Version
|
187
198
|
version: 1.0.2
|
188
199
|
none: false
|
189
|
-
requirement: *
|
200
|
+
requirement: *2476
|
190
201
|
prerelease: false
|
191
202
|
type: :development
|
192
203
|
- !ruby/object:Gem::Dependency
|
193
204
|
name: rspec
|
194
|
-
version_requirements: &
|
205
|
+
version_requirements: &2492 !ruby/object:Gem::Requirement
|
195
206
|
requirements:
|
196
207
|
- - ~>
|
197
208
|
- !ruby/object:Gem::Version
|
198
209
|
version: 2.6.0
|
199
210
|
none: false
|
200
|
-
requirement: *
|
211
|
+
requirement: *2492
|
201
212
|
prerelease: false
|
202
213
|
type: :development
|
203
214
|
description: ''
|
@@ -213,59 +224,33 @@ files:
|
|
213
224
|
- Rakefile
|
214
225
|
- euston-daemons.gemspec
|
215
226
|
- lib/euston-daemons.rb
|
216
|
-
- lib/euston-daemons/command_processor_daemon/config/environment.rb
|
217
|
-
- lib/euston-daemons/command_processor_daemon/lib/clients/command_handler.rb
|
218
|
-
- lib/euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message.rb
|
219
|
-
- lib/euston-daemons/command_processor_daemon/lib/daemon.rb
|
220
|
-
- lib/euston-daemons/command_processor_daemon/lib/mongo_models/failed_message.rb
|
221
|
-
- lib/euston-daemons/command_processor_daemon/rake_task.rb
|
222
227
|
- lib/euston-daemons/euston/daemon.rb
|
223
|
-
- lib/euston-daemons/euston/daemon_client.rb
|
224
228
|
- lib/euston-daemons/euston/daemon_component.rb
|
229
|
+
- lib/euston-daemons/euston/daemon_component_host.rb
|
225
230
|
- lib/euston-daemons/euston/daemon_environment.rb
|
226
|
-
- lib/euston-daemons/
|
227
|
-
- lib/euston-daemons/
|
228
|
-
- lib/euston-daemons/
|
229
|
-
- lib/euston-daemons/
|
230
|
-
- lib/euston-daemons/
|
231
|
-
- lib/euston-daemons/
|
232
|
-
- lib/euston-daemons/
|
233
|
-
- lib/euston-daemons/
|
234
|
-
- lib/euston-daemons/
|
235
|
-
- lib/euston-daemons/
|
236
|
-
- lib/euston-daemons/
|
237
|
-
- lib/euston-daemons/
|
238
|
-
- lib/euston-daemons/
|
239
|
-
- lib/euston-daemons/
|
240
|
-
- lib/euston-daemons/
|
241
|
-
- lib/euston-daemons/
|
242
|
-
- lib/euston-daemons/message_buffer_daemon/lib/clients/message_logger.rb
|
243
|
-
- lib/euston-daemons/message_buffer_daemon/lib/clients/mongo_model_accessors.rb
|
244
|
-
- lib/euston-daemons/message_buffer_daemon/lib/daemon.rb
|
245
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_buffer.rb
|
246
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_log.rb
|
247
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_buffer.rb
|
248
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_log.rb
|
249
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_buffer.rb
|
250
|
-
- lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_log.rb
|
251
|
-
- lib/euston-daemons/message_buffer_daemon/rake_task.rb
|
231
|
+
- lib/euston-daemons/euston/exceptions.rb
|
232
|
+
- lib/euston-daemons/euston/stopwatch.rb
|
233
|
+
- lib/euston-daemons/pipeline/config/environment.rb
|
234
|
+
- lib/euston-daemons/pipeline/lib/command_logger/component.rb
|
235
|
+
- lib/euston-daemons/pipeline/lib/command_logger/log.rb
|
236
|
+
- lib/euston-daemons/pipeline/lib/command_processor/component.rb
|
237
|
+
- lib/euston-daemons/pipeline/lib/command_processor/default_handlers/retry_failed_message.rb
|
238
|
+
- lib/euston-daemons/pipeline/lib/command_processor/failed_message.rb
|
239
|
+
- lib/euston-daemons/pipeline/lib/daemon.rb
|
240
|
+
- lib/euston-daemons/pipeline/lib/event_processor/component.rb
|
241
|
+
- lib/euston-daemons/pipeline/lib/event_processor/default_handlers/message_failure.rb
|
242
|
+
- lib/euston-daemons/pipeline/lib/event_store_dispatcher/component.rb
|
243
|
+
- lib/euston-daemons/pipeline/lib/message_buffer/buffer.rb
|
244
|
+
- lib/euston-daemons/pipeline/lib/message_buffer/component.rb
|
245
|
+
- lib/euston-daemons/pipeline/lib/snapshotter/component.rb
|
246
|
+
- lib/euston-daemons/pipeline/rake_task.rb
|
252
247
|
- lib/euston-daemons/rake_task.rb
|
253
248
|
- lib/euston-daemons/rake_tasks.rb
|
254
|
-
- lib/euston-daemons/snapshot_daemon/lib/clients/snapshotter.rb
|
255
249
|
- lib/euston-daemons/version.rb
|
256
|
-
-
|
257
|
-
-
|
258
|
-
-
|
259
|
-
-
|
260
|
-
- sample/event_handlers.rb
|
261
|
-
- sample/event_processor_daemon_config.yml
|
262
|
-
- sample/message_buffer_daemon_config.yml
|
263
|
-
- sample/mongoid_config.yml
|
264
|
-
- sample/pids/.placeholder
|
265
|
-
- spec/daemons/command_buffer_publisher_spec.rb
|
266
|
-
- spec/daemons/command_handler_spec.rb
|
267
|
-
- spec/daemons/event_handler_spec.rb
|
268
|
-
- spec/daemons/snapshot_client_spec.rb
|
250
|
+
- spec/daemons/command_processor_spec.rb
|
251
|
+
- spec/daemons/event_processor_spec.rb
|
252
|
+
- spec/daemons/message_buffer_spec.rb
|
253
|
+
- spec/daemons/snapshotter_spec.rb
|
269
254
|
- spec/spec_helper.rb
|
270
255
|
- spec/support/factories/commands.rb
|
271
256
|
- spec/support/factories/commit.rb
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'jessica'
|
2
|
-
require 'euston-rabbitmq'
|
3
|
-
|
4
|
-
require 'euston-daemons/command_processor_daemon/lib/mongo_models/failed_message'
|
5
|
-
require 'euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message'
|
6
|
-
require 'euston-daemons/command_processor_daemon/lib/clients/command_handler'
|
7
|
-
require 'euston-daemons/command_processor_daemon/lib/daemon'
|
8
|
-
|
9
|
-
module Euston
|
10
|
-
module CommandProcessorDaemon
|
11
|
-
class DaemonEnvironment < Euston::DaemonEnvironment
|
12
|
-
class << self
|
13
|
-
attr_accessor :command_handler_namespaces, :client_instances
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize data
|
17
|
-
@logger = data[:logger]
|
18
|
-
@amqp_config = ErbYaml.read data[:amqp_config_path], data[:environment]
|
19
|
-
@daemon_config = ErbYaml.read data[:daemon_config_path], data[:environment]
|
20
|
-
@mongoid_config = ErbYaml.read data[:mongoid_config_path], data[:environment]
|
21
|
-
|
22
|
-
self.class.client_instances = @daemon_config[:client_instances]
|
23
|
-
self.class.command_handler_namespaces = data[:command_handler_namespaces]
|
24
|
-
end
|
25
|
-
|
26
|
-
def setup
|
27
|
-
setup_safely @daemon_config[:hoptoad_key]
|
28
|
-
setup_amqp @amqp_config
|
29
|
-
setup_mongo @mongoid_config
|
30
|
-
setup_euston @mongoid_config[:event_store_database]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Euston
|
2
|
-
module CommandProcessorDaemon
|
3
|
-
class CommandHandler < Euston::DaemonClient
|
4
|
-
def initialize channel, handlers, logger
|
5
|
-
@channel = channel
|
6
|
-
@channel.prefetch 1
|
7
|
-
@handlers = handlers
|
8
|
-
@log = logger
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def next_iteration
|
14
|
-
message_received = Proc.new do |message|
|
15
|
-
command_headers = CommandHeaders.from_hash(message[:headers]).freeze
|
16
|
-
command_body = message[:body].freeze
|
17
|
-
|
18
|
-
handler_type = command_headers.type.to_s.camelize.to_sym
|
19
|
-
handler_method_name = "__version__#{command_headers.version}"
|
20
|
-
reference = @handlers.find { |reference| reference.name == handler_type }
|
21
|
-
|
22
|
-
if reference.nil?
|
23
|
-
@log.debug "Delivering command #{command_headers} to command bus"
|
24
|
-
Euston::CommandBus.publish command_headers, command_body
|
25
|
-
else
|
26
|
-
@log.debug "Delivering command #{command_headers} to #{reference.name}.#{handler_method_name}"
|
27
|
-
reference.handler.new.send handler_method_name, command_headers, command_body
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
Euston::RabbitMq::RetryingSubscription.new(@channel, :command_handlers, @log)
|
32
|
-
.when(:message_received => message_received)
|
33
|
-
.subscribe
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/lib/euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
module Euston
|
2
|
-
module CommandProcessorDaemon
|
3
|
-
module CommandHandlers
|
4
|
-
class RetryFailedMessage
|
5
|
-
include Euston::CommandHandler
|
6
|
-
|
7
|
-
version 1 do |headers, command|
|
8
|
-
model = MongoModel::FailedMessage.new DaemonEnvironment.event_store_mongodb
|
9
|
-
message = model.get_by_id command[:id]
|
10
|
-
|
11
|
-
unless message.nil?
|
12
|
-
routing_key = message['routing_key']
|
13
|
-
exchange = routing_key.split('.').first
|
14
|
-
|
15
|
-
headers = message['headers'].merge(:id => command[:id],
|
16
|
-
:type => message['type'],
|
17
|
-
:version => message['version'] )
|
18
|
-
|
19
|
-
if exchange == 'commands'
|
20
|
-
buffer = MessageBufferDaemon::MongoModel::CommandBuffer
|
21
|
-
elsif exchange == 'events'
|
22
|
-
buffer = MessageBufferDaemon::MongoModel::EventBuffer
|
23
|
-
end
|
24
|
-
|
25
|
-
buffer = buffer.new DaemonEnvironment.event_store_mongodb
|
26
|
-
buffer.push :headers => headers,
|
27
|
-
:body => message['body']
|
28
|
-
|
29
|
-
model.remove_by_id command[:id]
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Euston
|
2
|
-
module CommandProcessorDaemon
|
3
|
-
class Daemon < Euston::Daemon
|
4
|
-
private
|
5
|
-
|
6
|
-
def pre_registration_setup
|
7
|
-
handler_finder = Euston::RabbitMq::HandlerFinder.new [Euston::CommandHandler]
|
8
|
-
handler_finder.namespaces.push Euston::CommandProcessorDaemon::CommandHandlers, *DaemonEnvironment.command_handler_namespaces
|
9
|
-
@handlers = handler_finder.find
|
10
|
-
|
11
|
-
binder = Euston::RabbitMq::CommandHandlerBinder.new @handlers
|
12
|
-
binder.ensure_bindings_exist
|
13
|
-
end
|
14
|
-
|
15
|
-
def register_components
|
16
|
-
(1..DaemonEnvironment.client_instances).each do |i|
|
17
|
-
register_component "command_handler_#{i}".to_sym, CommandHandler.new(AMQP::Channel.new, @handlers, @log)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|