euston-daemons 1.0.4-java → 1.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/Rakefile +2 -3
- data/euston-daemons.gemspec +61 -26
- data/lib/euston-daemons/command_processor_daemon/config/environment.rb +27 -18
- data/lib/euston-daemons/command_processor_daemon/lib/clients/command_handler.rb +37 -0
- data/lib/euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message.rb +35 -0
- data/lib/euston-daemons/command_processor_daemon/lib/daemon.rb +11 -32
- data/lib/euston-daemons/command_processor_daemon/lib/mongo_models/failed_message.rb +34 -0
- data/lib/euston-daemons/command_processor_daemon/rake_task.rb +15 -13
- data/lib/euston-daemons/euston/daemon.rb +93 -0
- data/lib/euston-daemons/euston/daemon_client.rb +24 -0
- data/lib/euston-daemons/euston/daemon_component.rb +65 -0
- data/lib/euston-daemons/euston/daemon_environment.rb +54 -0
- data/lib/euston-daemons/event_processor_daemon/config/environment.rb +27 -16
- data/lib/euston-daemons/event_processor_daemon/lib/clients/event_handler.rb +42 -0
- data/lib/euston-daemons/event_processor_daemon/lib/daemon.rb +13 -60
- data/lib/euston-daemons/event_processor_daemon/lib/event_handlers/message_failure.rb +27 -0
- data/lib/euston-daemons/event_processor_daemon/rake_task.rb +18 -16
- data/lib/euston-daemons/message_buffer_daemon/config/environment.rb +39 -25
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_cleanup.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_publisher.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_logger.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/euston_exchange_accessors.rb +15 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_cleanup.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_publisher.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_logger.rb +9 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_store_dispatcher.rb +25 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_cleanup.rb +52 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_publisher.rb +37 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_logger.rb +45 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/clients/mongo_model_accessors.rb +21 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/daemon.rb +11 -42
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_buffer.rb +11 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_log.rb +11 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_buffer.rb +11 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_log.rb +11 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_buffer.rb +57 -0
- data/lib/euston-daemons/message_buffer_daemon/lib/{read_model → mongo_models}/message_log.rb +4 -11
- data/lib/euston-daemons/message_buffer_daemon/rake_task.rb +13 -11
- data/lib/euston-daemons/rake_task.rb +41 -65
- data/lib/euston-daemons/rake_tasks.rb +5 -5
- data/lib/euston-daemons/snapshot_daemon/lib/clients/snapshotter.rb +43 -0
- data/lib/euston-daemons/version.rb +1 -1
- data/lib/euston-daemons.rb +6 -1
- data/sample/Rakefile +63 -0
- data/sample/amqp_config.yml +14 -0
- data/sample/command_handlers.rb +17 -0
- data/sample/command_processor_daemon_config.yml +9 -0
- data/sample/event_handlers.rb +21 -0
- data/sample/event_processor_daemon_config.yml +8 -0
- data/sample/message_buffer_daemon_config.yml +8 -0
- data/sample/mongoid_config.yml +13 -0
- data/sample/pids/.placeholder +0 -0
- data/spec/daemons/command_buffer_publisher_spec.rb +110 -0
- data/spec/daemons/command_handler_spec.rb +48 -0
- data/spec/daemons/event_handler_spec.rb +55 -0
- data/spec/daemons/snapshot_client_spec.rb +98 -0
- data/spec/spec_helper.rb +77 -0
- data/spec/support/factories/commands.rb +16 -0
- data/spec/support/factories/commit.rb +7 -0
- data/spec/support/factories/event_message.rb +12 -0
- data/spec/support/factories/events.rb +8 -0
- data/spec/support/filters.rb +14 -0
- data/spec/support/sample_model/commands.rb +14 -0
- data/spec/support/sample_model/counter.rb +36 -0
- data/spec/support/sample_model/counter2.rb +46 -0
- data/spec/support/stub_retrying_subscription.rb +9 -0
- metadata +134 -67
- data/lib/euston-daemons/command_processor_daemon/lib/components/command_handler_component.rb +0 -56
- data/lib/euston-daemons/command_processor_daemon/lib/settings.rb +0 -22
- data/lib/euston-daemons/event_processor_daemon/lib/components/event_handler_component.rb +0 -58
- data/lib/euston-daemons/event_processor_daemon/lib/settings.rb +0 -26
- data/lib/euston-daemons/framework/basic_component.rb +0 -33
- data/lib/euston-daemons/framework/channel_thread.rb +0 -22
- data/lib/euston-daemons/framework/component_shutdown.rb +0 -22
- data/lib/euston-daemons/framework/daemon.rb +0 -27
- data/lib/euston-daemons/framework/handler_bindings_component.rb +0 -56
- data/lib/euston-daemons/framework/queue.rb +0 -71
- data/lib/euston-daemons/message_buffer_daemon/lib/components/buffer_component.rb +0 -73
- data/lib/euston-daemons/message_buffer_daemon/lib/components/event_store_component.rb +0 -52
- data/lib/euston-daemons/message_buffer_daemon/lib/message_logger.rb +0 -54
- data/lib/euston-daemons/message_buffer_daemon/lib/publisher.rb +0 -56
- data/lib/euston-daemons/message_buffer_daemon/lib/settings.rb +0 -14
- data/lib/euston-daemons/message_buffer_daemon/lib/subscriber.rb +0 -60
@@ -0,0 +1,57 @@
|
|
1
|
+
module Euston
|
2
|
+
module MessageBufferDaemon
|
3
|
+
module MongoModel
|
4
|
+
class MessageBuffer
|
5
|
+
def initialize name, mongodb
|
6
|
+
mongodb.create_collection name unless mongodb.collection_names.include? name
|
7
|
+
|
8
|
+
@name = name
|
9
|
+
@collection = mongodb.collection name
|
10
|
+
@collection.ensure_index [ ['next_attempt', Mongo::ASCENDING] ], :unique => false, :name => "#{name}_next_attempt_index"
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :name
|
14
|
+
|
15
|
+
def buffer_new_message message, dispatched_at = nil
|
16
|
+
next_attempt = (dispatched_at || Time.now.to_f).to_f
|
17
|
+
|
18
|
+
@collection.save({ '_id' => message[:headers][:id],
|
19
|
+
'type' => message[:headers][:type],
|
20
|
+
'next_attempt' => next_attempt,
|
21
|
+
'next_attempt_for_humans' => Time.at(next_attempt),
|
22
|
+
'json' => ::ActiveSupport::JSON.encode(message) }, :safe => { :fsync => true })
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_next_message
|
26
|
+
query = { 'next_attempt' => { '$lte' => Time.now.to_f } }
|
27
|
+
@collection.find_one(query)
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_due_messages
|
31
|
+
query = { 'next_attempt' => { '$lte' => Time.now.to_f } }
|
32
|
+
order = [ 'next_attempt', Mongo::ASCENDING ]
|
33
|
+
|
34
|
+
@collection.find(query).sort(order)
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_by_id id
|
38
|
+
@collection.find_one({ '_id' => id })
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_next_attempt message
|
42
|
+
next_attempt = Time.now.to_f + 10
|
43
|
+
|
44
|
+
id = { '_id' => message['_id'] }
|
45
|
+
doc = { '$set' => { 'next_attempt' => next_attempt,
|
46
|
+
'next_attempt_for_humans' => Time.at(next_attempt) } }
|
47
|
+
|
48
|
+
@collection.update id, doc, :safe => { :fsync => true }
|
49
|
+
end
|
50
|
+
|
51
|
+
def remove_published_message id
|
52
|
+
@collection.remove({ '_id' => id }, :safe => { :fsync => true })
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/euston-daemons/message_buffer_daemon/lib/{read_model → mongo_models}/message_log.rb
RENAMED
@@ -1,24 +1,17 @@
|
|
1
1
|
module Euston
|
2
2
|
module MessageBufferDaemon
|
3
|
-
module
|
3
|
+
module MongoModel
|
4
4
|
class MessageLog
|
5
|
-
class << self
|
6
|
-
def commands
|
7
|
-
self.new "command_log", Euston::RabbitMq.event_store_mongodb
|
8
|
-
end
|
9
|
-
|
10
|
-
def events
|
11
|
-
self.new "event_log", Euston::RabbitMq.event_store_mongodb
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
5
|
def initialize name, mongodb
|
16
6
|
mongodb.create_collection name unless mongodb.collection_names.include? name
|
17
7
|
|
8
|
+
@name = name
|
18
9
|
@collection = mongodb.collection name
|
19
10
|
@collection.ensure_index [ ['timestamp', Mongo::ASCENDING] ], :unique => false, :name => "#{name}_timestamp_index"
|
20
11
|
end
|
21
12
|
|
13
|
+
attr_reader :name
|
14
|
+
|
22
15
|
def find_all
|
23
16
|
@collection.find({}, { :sort => [ 'timestamp', Mongo::DESCENDING ] })
|
24
17
|
end
|
@@ -2,8 +2,8 @@ module Euston
|
|
2
2
|
class MessageBufferRakeTask < Euston::Daemons::RakeTask
|
3
3
|
attr_accessor :amqp_config_path, :daemon_config_path, :mongoid_config_path
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
super(:message_buffer_daemon)
|
5
|
+
def initialize environment
|
6
|
+
super(environment, :message_buffer_daemon)
|
7
7
|
end
|
8
8
|
|
9
9
|
def before_creating_task
|
@@ -11,20 +11,22 @@ module Euston
|
|
11
11
|
@daemon_class = 'Euston::MessageBufferDaemon::Daemon'
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
14
|
+
def initialize_settings
|
15
|
+
@logger.debug "AMQP config path: #{@amqp_config_path}"
|
16
|
+
@data[:amqp_config_path] = @amqp_config_path
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
@logger.debug "Daemon config path: #{@daemon_config_path}"
|
19
|
+
@data[:daemon_config_path] = @daemon_config_path
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
@logger.debug "Mongoid config path: #{@mongoid_config_path}"
|
22
|
+
@data[:mongoid_config_path] = @mongoid_config_path
|
23
23
|
end
|
24
24
|
|
25
25
|
def load_environment
|
26
|
-
|
27
|
-
|
26
|
+
@logger.debug "Loading environment"
|
27
|
+
require 'euston-daemons/message_buffer_daemon/config/environment'
|
28
|
+
|
29
|
+
Euston::MessageBufferDaemon::DaemonEnvironment.new(@data).setup
|
28
30
|
end
|
29
31
|
end
|
30
32
|
end
|
@@ -15,11 +15,11 @@ module Euston
|
|
15
15
|
# Daemon class. Must be supplied as a string.
|
16
16
|
attr_accessor :daemon_class
|
17
17
|
|
18
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
#
|
22
|
-
attr_accessor :
|
18
|
+
# Logger instance. Defaults to writing to /var/log/euston.log.
|
19
|
+
attr_accessor :logger
|
20
|
+
|
21
|
+
# # Path to write the daemon pid file to
|
22
|
+
attr_accessor :pid_path
|
23
23
|
|
24
24
|
# Use verbose output. If this is set to true, the task will print the
|
25
25
|
# executed command to stdout.
|
@@ -28,67 +28,48 @@ module Euston
|
|
28
28
|
# true
|
29
29
|
attr_accessor :verbose
|
30
30
|
|
31
|
-
def initialize
|
32
|
-
@name =
|
33
|
-
@log_path = '/var/log/euston.log'
|
31
|
+
def initialize environment, name = :euston_daemon
|
32
|
+
@name = name
|
34
33
|
@verbose = true
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@pid_path = pid_path_for_env + "#{@name}.pid"
|
34
|
+
@environment = validate_environment environment
|
35
|
+
@data = { :environment => @environment }
|
39
36
|
|
40
37
|
yield self if block_given?
|
41
38
|
send :before_creating_task if respond_to? :before_creating_task
|
42
39
|
|
43
40
|
desc("Run a Euston daemon") unless ::Rake.application.last_comment
|
44
|
-
|
45
41
|
task name do
|
46
42
|
RakeFileUtils.send(:verbose, verbose) do
|
47
43
|
initialize_logger
|
44
|
+
write_pid_file
|
48
45
|
log_startup
|
49
|
-
|
50
|
-
load_framework
|
46
|
+
initialize_settings
|
51
47
|
load_environment
|
52
48
|
launch_and_wait_for_exit
|
53
49
|
log_shutdown
|
50
|
+
remove_pid_file
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
57
54
|
|
58
55
|
private
|
59
56
|
|
60
|
-
def
|
61
|
-
environment =
|
57
|
+
def validate_environment environment
|
58
|
+
environment = environment.to_s.downcase.to_sym
|
62
59
|
environments = [:development, :test, :staging, :production]
|
63
60
|
environment = :development unless environments.include? environment
|
64
61
|
environment
|
65
62
|
end
|
66
63
|
|
67
|
-
def pid_path_for_env
|
68
|
-
case get_environment
|
69
|
-
when :development, :test
|
70
|
-
'~/var/run/euston/'
|
71
|
-
else
|
72
|
-
'/var/run/euston/'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
64
|
def initialize_logger
|
77
|
-
|
65
|
+
@logger ||= Logger.new(STDOUT)
|
66
|
+
@data[:logger] = @logger
|
78
67
|
end
|
79
68
|
|
80
|
-
def
|
69
|
+
def initialize_settings
|
81
70
|
# virtual
|
82
71
|
end
|
83
72
|
|
84
|
-
def rake_pid
|
85
|
-
if defined? Java
|
86
|
-
Java::JavaIo::File.new("/proc/self").canonical_file.name
|
87
|
-
else
|
88
|
-
File.readlink("/proc/self")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
73
|
def launch_and_wait_for_exit
|
93
74
|
ns = Object
|
94
75
|
|
@@ -97,26 +78,7 @@ module Euston
|
|
97
78
|
ns = ns.const_get c.to_sym
|
98
79
|
end
|
99
80
|
|
100
|
-
|
101
|
-
create_pid_file
|
102
|
-
trap_exit_signals daemon
|
103
|
-
daemon.run
|
104
|
-
remove_pid_file
|
105
|
-
end
|
106
|
-
|
107
|
-
def load_framework
|
108
|
-
EUSTON_LOG.debug "Loading framework"
|
109
|
-
require_rel 'framework'
|
110
|
-
end
|
111
|
-
|
112
|
-
def create_pid_file
|
113
|
-
File.open( @pid_path, 'w' ) { |f|
|
114
|
-
f.puts jvm_pid
|
115
|
-
}
|
116
|
-
end
|
117
|
-
|
118
|
-
def remove_pid_file
|
119
|
-
File.delete( @pid_path ) rescue Errno::ENOENT
|
81
|
+
ns.new(@data).run
|
120
82
|
end
|
121
83
|
|
122
84
|
def log_shutdown
|
@@ -130,17 +92,31 @@ module Euston
|
|
130
92
|
def print_log_banner banner
|
131
93
|
border = '-' * banner.length
|
132
94
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
95
|
+
@logger.info ''
|
96
|
+
@logger.info border
|
97
|
+
@logger.info banner
|
98
|
+
@logger.info border
|
99
|
+
@logger.info ''
|
100
|
+
end
|
101
|
+
|
102
|
+
def remove_pid_file
|
103
|
+
@logger.debug "Deleting pid file at #{@pid_file}"
|
104
|
+
|
105
|
+
File.delete @pid_file rescue Errno::ENOENT
|
138
106
|
end
|
139
107
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
143
|
-
|
108
|
+
def write_pid_file
|
109
|
+
@pid_file = File.join pid_path, "#{@name}.pid"
|
110
|
+
|
111
|
+
if defined? Java
|
112
|
+
@pid = Java::JavaIo::File.new("/proc/self").canonical_file.name
|
113
|
+
else
|
114
|
+
@pid = File.readlink("/proc/self")
|
115
|
+
end
|
116
|
+
|
117
|
+
@logger.debug "Writing pid #{@pid} to #{@pid_file}"
|
118
|
+
|
119
|
+
File.open(@pid_file, 'w') { |f| f.puts @pid }
|
144
120
|
end
|
145
121
|
end
|
146
122
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'euston-daemons'
|
2
|
-
require 'rake/tasklib'
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
require 'rake/tasklib'
|
4
|
+
require 'euston-daemons/rake_task'
|
5
|
+
require 'euston-daemons/command_processor_daemon/rake_task'
|
6
|
+
require 'euston-daemons/event_processor_daemon/rake_task'
|
7
|
+
require 'euston-daemons/message_buffer_daemon/rake_task'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Euston
|
2
|
+
module SnapshotDaemon
|
3
|
+
class Snapshotter < Euston::DaemonClient
|
4
|
+
def initialize event_store, threshold, logger
|
5
|
+
@event_store = event_store
|
6
|
+
@threshold = threshold
|
7
|
+
@log = logger
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def next_iteration
|
13
|
+
begin
|
14
|
+
stream_heads = @event_store.get_streams_to_snapshot @threshold
|
15
|
+
@log.debug "Found #{stream_heads.length} stream(s) eligible for snapshotting (threshold is #{@threshold})"
|
16
|
+
|
17
|
+
stream_heads.each do |stream_head|
|
18
|
+
pair = @event_store.get_snapshot_stream_pair stream_head.stream_id
|
19
|
+
|
20
|
+
loader = RabbitMq::ConstantLoader.new
|
21
|
+
loader.when(:hit => ->(klass) { take_snapshot klass, pair },
|
22
|
+
:miss => ->(type) { Safely.report! "Snapshotter was unable to find a class: #{type}" })
|
23
|
+
|
24
|
+
loader.load pair.stream.committed_headers[:aggregate_type]
|
25
|
+
end
|
26
|
+
end until stopped || stream_heads.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def take_snapshot klass, pair
|
30
|
+
instance = klass.hydrate pair.stream, pair.snapshot
|
31
|
+
snapshot = instance.take_snapshot
|
32
|
+
snapshot = EventStore::Snapshot.new pair.stream.stream_id,
|
33
|
+
pair.stream.stream_revision,
|
34
|
+
snapshot[:payload],
|
35
|
+
:version => snapshot[:version]
|
36
|
+
|
37
|
+
@log.debug "Writing snapshot: #{snapshot.inspect}"
|
38
|
+
|
39
|
+
@event_store.add_snapshot snapshot
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/euston-daemons.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
require 'erb-yaml'
|
1
2
|
require 'hollywood'
|
2
3
|
require 'logger'
|
3
|
-
require 'require_all'
|
4
4
|
|
5
5
|
if RUBY_PLATFORM.to_s == 'java'
|
6
6
|
module Uuid
|
@@ -9,3 +9,8 @@ if RUBY_PLATFORM.to_s == 'java'
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
+
|
13
|
+
require 'euston-daemons/euston/daemon_environment'
|
14
|
+
require 'euston-daemons/euston/daemon_client'
|
15
|
+
require 'euston-daemons/euston/daemon_component'
|
16
|
+
require 'euston-daemons/euston/daemon'
|
data/sample/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
unless defined?(Bundler)
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'bundler'
|
6
|
+
rescue => e
|
7
|
+
STDERR.puts e.message
|
8
|
+
STDERR.puts "Try running `bundle install`."
|
9
|
+
exit!
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
RAKE_ENV = (ENV['RAKE_ENV'] || 'development').to_sym
|
14
|
+
|
15
|
+
Bundler.require :default, RAKE_ENV
|
16
|
+
|
17
|
+
require 'euston'
|
18
|
+
require 'euston-daemons/rake_tasks'
|
19
|
+
|
20
|
+
sample_path = File.dirname __FILE__
|
21
|
+
pid_path = File.join sample_path, 'pids'
|
22
|
+
amqp_config_path = File.join sample_path, "amqp_config.yml"
|
23
|
+
mongoid_config_path = File.join sample_path, 'mongoid_config.yml'
|
24
|
+
|
25
|
+
require 'erb-yaml'
|
26
|
+
amqp_config = ErbYaml.read amqp_config_path, RAKE_ENV
|
27
|
+
|
28
|
+
rabbitmqadmin = RabbitMqAdminCli.new
|
29
|
+
rabbitmqadmin.initialize_vhost amqp_config[:vhost]
|
30
|
+
rabbitmqadmin.initialize_user amqp_config[:vhost], amqp_config[:user], amqp_config[:pass]
|
31
|
+
|
32
|
+
desc "Run the command processor daemon"
|
33
|
+
Euston::CommandProcessorRakeTask.new(RAKE_ENV) do |t|
|
34
|
+
require File.join sample_path, 'command_handlers'
|
35
|
+
|
36
|
+
t.amqp_config_path = amqp_config_path
|
37
|
+
t.command_handler_namespaces = ['Euston::Daemons::Sample::CommandHandlers']
|
38
|
+
t.daemon_config_path = File.join sample_path, "command_processor_daemon_config.yml"
|
39
|
+
t.logger = Logger.new(STDOUT)
|
40
|
+
t.mongoid_config_path = mongoid_config_path
|
41
|
+
t.pid_path = pid_path
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Run the event processor daemon"
|
45
|
+
Euston::EventProcessorRakeTask.new(RAKE_ENV) do |t|
|
46
|
+
require File.join sample_path, 'event_handlers'
|
47
|
+
|
48
|
+
t.amqp_config_path = amqp_config_path
|
49
|
+
t.daemon_config_path = File.join sample_path, "event_processor_daemon_config.yml"
|
50
|
+
t.event_handler_namespaces = ['Euston::Daemons::Sample::EventHandlers']
|
51
|
+
t.logger = Logger.new(STDOUT)
|
52
|
+
t.mongoid_config_path = mongoid_config_path
|
53
|
+
t.pid_path = pid_path
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "Run the message buffer daemon"
|
57
|
+
Euston::MessageBufferRakeTask.new(RAKE_ENV) do |t|
|
58
|
+
t.amqp_config_path = amqp_config_path
|
59
|
+
t.daemon_config_path = File.join sample_path, "message_buffer_daemon_config.yml"
|
60
|
+
t.logger = Logger.new(STDOUT)
|
61
|
+
t.mongoid_config_path = mongoid_config_path
|
62
|
+
t.pid_path = pid_path
|
63
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Euston
|
2
|
+
module Daemons
|
3
|
+
module Sample
|
4
|
+
module CommandHandlers
|
5
|
+
class ContactCustomer
|
6
|
+
include Euston::CommandHandler
|
7
|
+
version 1
|
8
|
+
end
|
9
|
+
|
10
|
+
class PostGoods
|
11
|
+
include Euston::CommandHandler
|
12
|
+
version 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Euston
|
2
|
+
module Daemons
|
3
|
+
module Sample
|
4
|
+
module EventHandlers
|
5
|
+
class SalesOffice
|
6
|
+
include Euston::EventHandler
|
7
|
+
|
8
|
+
consumes :customer_contacted, 1 do |headers, event|
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Warehouse
|
13
|
+
include Euston::EventHandler
|
14
|
+
|
15
|
+
consumes :goods_posted, 1 do |headers, event|
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
host: localhost
|
3
|
+
port: 27017
|
4
|
+
safe: true
|
5
|
+
use_utc: true
|
6
|
+
event_store_database: euston-daemons-sample-event-store
|
7
|
+
read_model_database: euston-daemons-sample-read-model
|
8
|
+
|
9
|
+
development:
|
10
|
+
<<: *defaults
|
11
|
+
|
12
|
+
test:
|
13
|
+
<<: *defaults
|
File without changes
|