active_projection 0.4.3 → 0.5.0.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWVkZDQwZWNhZDg1YWE3OGJiMGI3ZDAzNGIxMDgzYWQ5MzVlZDJmYQ==
5
- data.tar.gz: !binary |-
6
- NjVlMmEzOTYwZTg0MWRhMzgyZTk4ZjU2ZTU4ZTFhNTk4YzUzMjdkNA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MzM2NTcwNDhiYzdhM2MyZTFiZTYwNzU5ZjJmNDJlYTQwOTBkNDYwNzAzNGUy
10
- M2MwZTdhNzk1NzYyY2RkODdlYjk4M2UwNGM2YTZlOTdkN2FhMGRmOTIzMTRl
11
- NDg0MzIzYzY4NDAxNDJmYTdhMTU0ODRlMGIyNjgwOWIxNTRiODY=
12
- data.tar.gz: !binary |-
13
- ZGU4Nzc0Y2M0YjZkNTczMTI4NDE4NmM5NjRiZjlkMGQyOTI0ZGM3MjgyOWFk
14
- Yjk5ZTc4NzFlMzg3ZWVjY2YyMTU3ZTY2N2M0ZWIyYjFkZDg2Njg4YWFhYTQ5
15
- ZWNjMmQxMzE4YWQ5YTA1ZTM4NmE5YjMxNTdhODBiYTY5NDg4NmQ=
2
+ SHA1:
3
+ metadata.gz: 692a897b9d9a050c06c7e291d2b78e117570fb1b
4
+ data.tar.gz: 1d0c343a8fcef67fe660c5064c784bc218d7df9d
5
+ SHA512:
6
+ metadata.gz: 3b6152bfc7ee7ff65c300e18ba7d8aaa0f0fb1fd144836609e5aa75860e27c2e956c2b28f247b998691487b864a36d49029b4121b2b4ea9b23a346545f6537a3
7
+ data.tar.gz: 4461c4e7d75b65fc75133ca318726df79c16cb9875968a3a336590061c70f1a28d4c6aa79df85f5900c098036cb0cd5d262d0b31d086097b8070dc3856656cd9
@@ -19,6 +19,14 @@ module ActiveProjection
19
19
  Projection.find(id).update! solid: false
20
20
  end
21
21
 
22
+ def self.get_all_broken
23
+ broken_projections = []
24
+ Projection.all.to_a.each do |p|
25
+ broken_projections << p.class_name unless p.solid?
26
+ end
27
+ broken_projections
28
+ end
29
+
22
30
  def self.solid?(id)
23
31
  @@broken[id] ||= Projection.find(id).solid
24
32
  end
@@ -55,7 +55,9 @@ module ActiveProjection
55
55
 
56
56
  def replay_done?(body)
57
57
  if 'replay_done' == body
58
- LOGGER.debug 'Projections should be up to date now'
58
+ LOGGER.debug 'All replayed events received'
59
+ broken_projections = ProjectionRepository.get_all_broken
60
+ LOGGER.error "These projections are still broken: #{broken_projections.join(", ")}" unless broken_projections.empty?
59
61
  replay_queue.unbind(resend_exchange)
60
62
  return true
61
63
  end
@@ -20,18 +20,21 @@ module ActiveProjection
20
20
  end
21
21
 
22
22
  def evaluate(headers)
23
- return false unless solid? || headers[:replayed]
23
+ unless solid?
24
+ LOGGER.error "[#{self.class.name}] is broken"
25
+ return false
26
+ end
24
27
  last_id = fetch_last_id
25
28
  event_id = headers[:id]
26
29
  case
27
30
  when last_id + 1 == event_id
28
31
  true
29
32
  when last_id >= event_id
30
- LOGGER.debug "[#{self.class.name}] event #{event_id} already processed"
33
+ LOGGER.debug "[#{self.class.name}]: event #{event_id} already processed"
31
34
  false
32
35
  when last_id < event_id
33
36
  set_broken
34
- LOGGER.debug "[#{self.class.name}] #{event_id - last_id} events are missing"
37
+ LOGGER.error "[#{self.class.name}]: #{event_id - last_id} events are missing"
35
38
  false
36
39
  end
37
40
  end
@@ -46,13 +49,15 @@ module ActiveProjection
46
49
  else
47
50
  self.send method, event, headers
48
51
  end
49
- rescue Exception
50
- LOGGER.debug "[#{self.class.name}] error processing #{event_type}[#{event_id}]"
51
- raise
52
+ rescue Exception => e
53
+ LOGGER.error "[#{self.class.name}]: error processing #{event_type}[#{event_id}]\n#{e.message}\n#{e.backtrace}"
54
+ set_broken
52
55
  end
53
56
  end
54
- update_last_id event_id
55
- LOGGER.debug "[#{self.class.name}] sucessfully processed #{event_type}[#{event_id}]"
57
+ if solid?
58
+ update_last_id event_id
59
+ LOGGER.debug "[#{self.class.name}]: sucessfully processed #{event_type}[#{event_id}]"
60
+ end
56
61
  end
57
62
 
58
63
  private
@@ -62,7 +67,7 @@ module ActiveProjection
62
67
  def self.method_name_to_event_type(method_name)
63
68
  method_name.to_s.gsub('__', '/').camelcase.to_sym
64
69
  end
65
-
70
+
66
71
  def projection_id
67
72
  @projection_id ||= ProjectionRepository.create_or_get(self.class.name).id
68
73
  end
@@ -26,9 +26,14 @@ module ActiveProjection
26
26
 
27
27
  cattr_accessor :base_path
28
28
  cattr_accessor :config_file
29
+ cattr_accessor :rails_config_file
29
30
 
30
31
  def config_file
31
- self.class.config_file || File.expand_path('config/disco.yml', base_path)
32
+ self.class.config_file ||= File.expand_path('config/disco.yml', base_path)
33
+ end
34
+
35
+ def rails_config_file
36
+ self.class.rails_config_file ||= File.expand_path('config/database.yml', base_path)
32
37
  end
33
38
 
34
39
  private
@@ -40,7 +45,7 @@ module ActiveProjection
40
45
  {
41
46
  projection_database: {
42
47
  adapter: 'sqlite3',
43
- database: File.expand_path('db/projection.sqlite3', base_path)
48
+ database: File.expand_path('db/production.sqlite3', base_path)
44
49
  },
45
50
  event_connection: {
46
51
  scheme: 'amqp',
@@ -55,6 +60,8 @@ module ActiveProjection
55
60
  def parse_options(args)
56
61
  options = default_options
57
62
  options.merge! YAML.load_file(config_file)[env].deep_symbolize_keys! unless config_file.blank?
63
+ options[:projection_database] = YAML.load_file(rails_config_file)[env].deep_symbolize_keys! unless rails_config_file.blank?
64
+ options
58
65
  end
59
66
  end
60
67
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveProjection
2
2
  # Returns the version of the currently loaded ActiveProjection as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new '0.4.3'
4
+ Gem::Version.new '0.5.0.pre'
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
- require 'factory_girl'
4
-
5
- require 'active_projection'
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require 'factory_girl'
4
+
5
+ require 'active_projection'
6
+ LOGGER ||= Logger.new(STDOUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_projection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Reischuck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-18 00:00:00.000000000 Z
11
+ date: 2014-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_event
@@ -16,19 +16,19 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.3
19
+ version: 0.5.0.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.4.3
26
+ version: 0.5.0.pre
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>'
31
+ - - '>'
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.2.0
34
34
  - - <
@@ -38,7 +38,7 @@ dependencies:
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ! '>'
41
+ - - '>'
42
42
  - !ruby/object:Gem::Version
43
43
  version: 3.2.0
44
44
  - - <
@@ -48,7 +48,7 @@ dependencies:
48
48
  name: activemodel
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ! '>'
51
+ - - '>'
52
52
  - !ruby/object:Gem::Version
53
53
  version: 3.2.0
54
54
  - - <
@@ -58,7 +58,7 @@ dependencies:
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ! '>'
61
+ - - '>'
62
62
  - !ruby/object:Gem::Version
63
63
  version: 3.2.0
64
64
  - - <
@@ -68,14 +68,14 @@ dependencies:
68
68
  name: bunny
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - ! '>='
71
+ - - '>='
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  type: :runtime
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ! '>='
78
+ - - '>='
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  - !ruby/object:Gem::Dependency
@@ -96,56 +96,56 @@ dependencies:
96
96
  name: rake
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ! '>='
99
+ - - '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ! '>='
106
+ - - '>='
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: rspec
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ! '>='
113
+ - - '>='
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ! '>='
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: factory_girl
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ! '>='
127
+ - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ! '>='
134
+ - - '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: coveralls
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - ! '>='
141
+ - - '>='
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - ! '>='
148
+ - - '>='
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  description: Projection environment for rails-disco
@@ -183,17 +183,17 @@ require_paths:
183
183
  - lib
184
184
  required_ruby_version: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - ! '>='
186
+ - - '>='
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0'
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - ! '>='
191
+ - - '>'
192
192
  - !ruby/object:Gem::Version
193
- version: '0'
193
+ version: 1.3.1
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.0.3
196
+ rubygems_version: 2.1.11
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Projection related stuff (part of rails-disco)
@@ -204,4 +204,3 @@ test_files:
204
204
  - spec/models/projection_repository_spec.rb
205
205
  - spec/spec_helper.rb
206
206
  - spec/support/active_record.rb
207
- has_rdoc: