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.
Files changed (84) hide show
  1. data/Gemfile +3 -1
  2. data/Rakefile +2 -3
  3. data/euston-daemons.gemspec +61 -26
  4. data/lib/euston-daemons/command_processor_daemon/config/environment.rb +27 -18
  5. data/lib/euston-daemons/command_processor_daemon/lib/clients/command_handler.rb +37 -0
  6. data/lib/euston-daemons/command_processor_daemon/lib/command_handlers/retry_failed_message.rb +35 -0
  7. data/lib/euston-daemons/command_processor_daemon/lib/daemon.rb +11 -32
  8. data/lib/euston-daemons/command_processor_daemon/lib/mongo_models/failed_message.rb +34 -0
  9. data/lib/euston-daemons/command_processor_daemon/rake_task.rb +15 -13
  10. data/lib/euston-daemons/euston/daemon.rb +93 -0
  11. data/lib/euston-daemons/euston/daemon_client.rb +24 -0
  12. data/lib/euston-daemons/euston/daemon_component.rb +65 -0
  13. data/lib/euston-daemons/euston/daemon_environment.rb +54 -0
  14. data/lib/euston-daemons/event_processor_daemon/config/environment.rb +27 -16
  15. data/lib/euston-daemons/event_processor_daemon/lib/clients/event_handler.rb +42 -0
  16. data/lib/euston-daemons/event_processor_daemon/lib/daemon.rb +13 -60
  17. data/lib/euston-daemons/event_processor_daemon/lib/event_handlers/message_failure.rb +27 -0
  18. data/lib/euston-daemons/event_processor_daemon/rake_task.rb +18 -16
  19. data/lib/euston-daemons/message_buffer_daemon/config/environment.rb +39 -25
  20. data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_cleanup.rb +9 -0
  21. data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_buffer_publisher.rb +9 -0
  22. data/lib/euston-daemons/message_buffer_daemon/lib/clients/command_logger.rb +9 -0
  23. data/lib/euston-daemons/message_buffer_daemon/lib/clients/euston_exchange_accessors.rb +15 -0
  24. data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_cleanup.rb +9 -0
  25. data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_buffer_publisher.rb +9 -0
  26. data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_logger.rb +9 -0
  27. data/lib/euston-daemons/message_buffer_daemon/lib/clients/event_store_dispatcher.rb +25 -0
  28. data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_cleanup.rb +52 -0
  29. data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_buffer_publisher.rb +37 -0
  30. data/lib/euston-daemons/message_buffer_daemon/lib/clients/message_logger.rb +45 -0
  31. data/lib/euston-daemons/message_buffer_daemon/lib/clients/mongo_model_accessors.rb +21 -0
  32. data/lib/euston-daemons/message_buffer_daemon/lib/daemon.rb +11 -42
  33. data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_buffer.rb +11 -0
  34. data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/command_log.rb +11 -0
  35. data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_buffer.rb +11 -0
  36. data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/event_log.rb +11 -0
  37. data/lib/euston-daemons/message_buffer_daemon/lib/mongo_models/message_buffer.rb +57 -0
  38. data/lib/euston-daemons/message_buffer_daemon/lib/{read_model → mongo_models}/message_log.rb +4 -11
  39. data/lib/euston-daemons/message_buffer_daemon/rake_task.rb +13 -11
  40. data/lib/euston-daemons/rake_task.rb +41 -65
  41. data/lib/euston-daemons/rake_tasks.rb +5 -5
  42. data/lib/euston-daemons/snapshot_daemon/lib/clients/snapshotter.rb +43 -0
  43. data/lib/euston-daemons/version.rb +1 -1
  44. data/lib/euston-daemons.rb +6 -1
  45. data/sample/Rakefile +63 -0
  46. data/sample/amqp_config.yml +14 -0
  47. data/sample/command_handlers.rb +17 -0
  48. data/sample/command_processor_daemon_config.yml +9 -0
  49. data/sample/event_handlers.rb +21 -0
  50. data/sample/event_processor_daemon_config.yml +8 -0
  51. data/sample/message_buffer_daemon_config.yml +8 -0
  52. data/sample/mongoid_config.yml +13 -0
  53. data/sample/pids/.placeholder +0 -0
  54. data/spec/daemons/command_buffer_publisher_spec.rb +110 -0
  55. data/spec/daemons/command_handler_spec.rb +48 -0
  56. data/spec/daemons/event_handler_spec.rb +55 -0
  57. data/spec/daemons/snapshot_client_spec.rb +98 -0
  58. data/spec/spec_helper.rb +77 -0
  59. data/spec/support/factories/commands.rb +16 -0
  60. data/spec/support/factories/commit.rb +7 -0
  61. data/spec/support/factories/event_message.rb +12 -0
  62. data/spec/support/factories/events.rb +8 -0
  63. data/spec/support/filters.rb +14 -0
  64. data/spec/support/sample_model/commands.rb +14 -0
  65. data/spec/support/sample_model/counter.rb +36 -0
  66. data/spec/support/sample_model/counter2.rb +46 -0
  67. data/spec/support/stub_retrying_subscription.rb +9 -0
  68. metadata +134 -67
  69. data/lib/euston-daemons/command_processor_daemon/lib/components/command_handler_component.rb +0 -56
  70. data/lib/euston-daemons/command_processor_daemon/lib/settings.rb +0 -22
  71. data/lib/euston-daemons/event_processor_daemon/lib/components/event_handler_component.rb +0 -58
  72. data/lib/euston-daemons/event_processor_daemon/lib/settings.rb +0 -26
  73. data/lib/euston-daemons/framework/basic_component.rb +0 -33
  74. data/lib/euston-daemons/framework/channel_thread.rb +0 -22
  75. data/lib/euston-daemons/framework/component_shutdown.rb +0 -22
  76. data/lib/euston-daemons/framework/daemon.rb +0 -27
  77. data/lib/euston-daemons/framework/handler_bindings_component.rb +0 -56
  78. data/lib/euston-daemons/framework/queue.rb +0 -71
  79. data/lib/euston-daemons/message_buffer_daemon/lib/components/buffer_component.rb +0 -73
  80. data/lib/euston-daemons/message_buffer_daemon/lib/components/event_store_component.rb +0 -52
  81. data/lib/euston-daemons/message_buffer_daemon/lib/message_logger.rb +0 -54
  82. data/lib/euston-daemons/message_buffer_daemon/lib/publisher.rb +0 -56
  83. data/lib/euston-daemons/message_buffer_daemon/lib/settings.rb +0 -14
  84. data/lib/euston-daemons/message_buffer_daemon/lib/subscriber.rb +0 -60
@@ -0,0 +1,11 @@
1
+ module Euston
2
+ module MessageBufferDaemon
3
+ module MongoModel
4
+ class CommandBuffer < MessageBuffer
5
+ def initialize event_store_mongodb
6
+ super 'command_buffer', event_store_mongodb
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Euston
2
+ module MessageBufferDaemon
3
+ module MongoModel
4
+ class CommandLog < MessageLog
5
+ def initialize event_store_mongodb
6
+ super 'command_log', event_store_mongodb
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Euston
2
+ module MessageBufferDaemon
3
+ module MongoModel
4
+ class EventBuffer < MessageBuffer
5
+ def initialize event_store_mongodb
6
+ super 'event_buffer', event_store_mongodb
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Euston
2
+ module MessageBufferDaemon
3
+ module MongoModel
4
+ class EventLog < MessageLog
5
+ def initialize event_store_mongodb
6
+ super 'event_log', event_store_mongodb
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -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
@@ -1,24 +1,17 @@
1
1
  module Euston
2
2
  module MessageBufferDaemon
3
- module ReadModel
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 initialize_paths
15
- EUSTON_LOG.debug "AMQP config path: #{@amqp_config_path}"
16
- Object.const_set :AMQP_CONFIG_PATH, @amqp_config_path
14
+ def initialize_settings
15
+ @logger.debug "AMQP config path: #{@amqp_config_path}"
16
+ @data[:amqp_config_path] = @amqp_config_path
17
17
 
18
- EUSTON_LOG.debug "Daemon config path: #{@daemon_config_path}"
19
- Object.const_set :DAEMON_CONFIG_PATH, @daemon_config_path
18
+ @logger.debug "Daemon config path: #{@daemon_config_path}"
19
+ @data[:daemon_config_path] = @daemon_config_path
20
20
 
21
- EUSTON_LOG.debug "Mongoid config path: #{@mongoid_config_path}"
22
- Object.const_set :MONGOID_CONFIG_PATH, @mongoid_config_path
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
- EUSTON_LOG.debug "Loading environment"
27
- require_rel 'config/environment.rb'
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
- # Log file path
19
- #
20
- # default:
21
- # /var/log/euston.log
22
- attr_accessor :log_path
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(*args)
32
- @name = args.shift || :eustondaemon
33
- @log_path = '/var/log/euston.log'
31
+ def initialize environment, name = :euston_daemon
32
+ @name = name
34
33
  @verbose = true
35
-
36
- Object.const_set :EUSTON_ENV, get_environment unless Object.const_defined? :EUSTON_ENV
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
- initialize_paths
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 get_environment
61
- environment = ENV['EUSTON_ENV'].to_s.downcase.to_sym
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
- Object.const_set :EUSTON_LOG, Logger.new(@log_path.gsub(/\.log$/, ".#{EUSTON_ENV}.log"))
65
+ @logger ||= Logger.new(STDOUT)
66
+ @data[:logger] = @logger
78
67
  end
79
68
 
80
- def initialize_paths
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
- daemon = ns.new
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
- EUSTON_LOG.info ''
134
- EUSTON_LOG.info border
135
- EUSTON_LOG.info banner
136
- EUSTON_LOG.info border
137
- EUSTON_LOG.info ''
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 trap_exit_signals daemon
141
- signals = %W(INT TERM) & Signal.list.keys
142
- signals.each { |sig| sig.freeze }.freeze
143
- signals.each { |sig| Signal.trap(sig) { daemon.queue.push(sig) } }
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
- require_rel 'rake_task.rb'
5
- require_rel 'command_processor_daemon/rake_task.rb'
6
- require_rel 'event_processor_daemon/rake_task.rb'
7
- require_rel 'message_buffer_daemon/rake_task.rb'
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
@@ -1,5 +1,5 @@
1
1
  module Euston
2
2
  module Daemons
3
- VERSION = "1.0.4"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -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,14 @@
1
+ defaults: &defaults
2
+ host: localhost
3
+ vhost: euston-daemons-sample
4
+ user: euston-daemons-sample-user
5
+ pass: password
6
+
7
+ development:
8
+ <<: *defaults
9
+
10
+ test:
11
+ <<: *defaults
12
+
13
+ production:
14
+ <<: *defaults
@@ -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,9 @@
1
+ defaults: &defaults
2
+ client_instances: 3
3
+ mongo_db_name: euston-daemons-sample-event-store
4
+
5
+ development:
6
+ <<: *defaults
7
+
8
+ test:
9
+ <<: *defaults
@@ -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,8 @@
1
+ defaults: &defaults
2
+ mongo_db_name: euston-daemons-sample-read-model
3
+
4
+ development:
5
+ <<: *defaults
6
+
7
+ test:
8
+ <<: *defaults
@@ -0,0 +1,8 @@
1
+ defaults: &defaults
2
+ debug: false
3
+
4
+ development:
5
+ <<: *defaults
6
+
7
+ test:
8
+ <<: *defaults
@@ -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