promiscuous 0.15.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,5 +14,9 @@ module Promiscuous::Common::Worker
14
14
  end
15
15
  end
16
16
 
17
+ def bareback?
18
+ !!ENV['BAREBACK']
19
+ end
20
+
17
21
  included { attr_accessor :stop, :options }
18
22
  end
@@ -30,6 +30,17 @@ module Promiscuous::Publisher::Mongoid::Defer
30
30
  Moped::Query.class_eval do
31
31
  alias_method :update_orig, :update
32
32
  def update(change, flags = nil)
33
+ change = promiscuous_seasoning(change)
34
+ update_orig(change, flags)
35
+ end
36
+
37
+ alias_method :modify_orig, :modify
38
+ def modify(change, options={})
39
+ change = promiscuous_seasoning(change) unless options[:bypass_promiscuous]
40
+ modify_orig(change, options)
41
+ end
42
+
43
+ def promiscuous_seasoning(change)
33
44
  if Promiscuous::Publisher::Mongoid::Defer.collections[@collection.name]
34
45
  change = change.dup
35
46
  change['$set'] ||= {}
@@ -37,7 +48,7 @@ module Promiscuous::Publisher::Mongoid::Defer
37
48
  change['$set'].merge!(:_psp => true)
38
49
  change['$inc'].merge!(:_psv => 1)
39
50
  end
40
- update_orig(change, flags)
51
+ change
41
52
  end
42
53
  end
43
54
  end
@@ -30,7 +30,8 @@ class Promiscuous::Publisher::Worker
30
30
  end
31
31
  end
32
32
  rescue Exception => e
33
- self.stop = true
33
+ self.stop = true unless bareback?
34
+
34
35
  unless e.is_a?(Promiscuous::Publisher::Error)
35
36
  e = Promiscuous::Publisher::Error.new(e, nil)
36
37
  end
@@ -42,7 +43,8 @@ class Promiscuous::Publisher::Worker
42
43
  def replicate_collection(klass)
43
44
  return if self.stop
44
45
  # TODO Check for indexes and if not there, bail out
45
- while instance = klass.where(:_psp => true).find_and_modify({'$unset' => {:_psp => 1}})
46
+ while instance = klass.where(:_psp => true).find_and_modify(
47
+ {'$unset' => {:_psp => 1}}, :bypass_promiscuous => true)
46
48
  replicate_instance(instance)
47
49
  end
48
50
  end
@@ -15,10 +15,13 @@ class Promiscuous::Subscriber::Worker
15
15
  rescue Exception => e
16
16
  e = Promiscuous::Subscriber::Error.new(e, payload)
17
17
 
18
- self.stop = true
19
- Promiscuous::AMQP.disconnect
20
- Promiscuous.error "[receive] FATAL #{e} #{e.backtrace.join("\n")}"
21
- Promiscuous.error "[receive] FATAL #{e}"
18
+ if bareback?
19
+ metadata.ack
20
+ else
21
+ self.stop = true
22
+ Promiscuous::AMQP.disconnect
23
+ end
24
+ Promiscuous.error "[receive] FATAL #{"skipping " if bareback?}#{e} #{e.backtrace.join("\n")}"
22
25
  Promiscuous::Config.error_handler.try(:call, e)
23
26
  end
24
27
  end
@@ -1,3 +1,3 @@
1
1
  module Promiscuous
2
- VERSION = '0.15.0'
2
+ VERSION = '0.16.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: promiscuous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.16.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-29 00:00:00.000000000 Z
13
+ date: 2012-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -116,42 +116,38 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
- - lib/promiscuous/amqp/bunny.rb
120
119
  - lib/promiscuous/amqp/null.rb
120
+ - lib/promiscuous/amqp/bunny.rb
121
121
  - lib/promiscuous/amqp/rubyamqp.rb
122
- - lib/promiscuous/common.rb
123
- - lib/promiscuous/common/class_helpers.rb
124
122
  - lib/promiscuous/common/lint.rb
125
123
  - lib/promiscuous/common/lint/base.rb
126
- - lib/promiscuous/common/options.rb
124
+ - lib/promiscuous/common/class_helpers.rb
127
125
  - lib/promiscuous/common/worker.rb
128
- - lib/promiscuous/config.rb
126
+ - lib/promiscuous/common/options.rb
129
127
  - lib/promiscuous/loader.rb
130
- - lib/promiscuous/observer.rb
131
- - lib/promiscuous/publisher.rb
132
- - lib/promiscuous/publisher/active_record.rb
133
128
  - lib/promiscuous/publisher/envelope.rb
134
- - lib/promiscuous/publisher/ephemeral.rb
135
- - lib/promiscuous/publisher/error.rb
136
129
  - lib/promiscuous/publisher/lint.rb
137
130
  - lib/promiscuous/publisher/lint/amqp.rb
138
131
  - lib/promiscuous/publisher/lint/attributes.rb
139
132
  - lib/promiscuous/publisher/lint/base.rb
140
133
  - lib/promiscuous/publisher/lint/class.rb
141
134
  - lib/promiscuous/publisher/lint/polymorphic.rb
142
- - lib/promiscuous/publisher/mock.rb
143
135
  - lib/promiscuous/publisher/mongoid/embedded.rb
144
136
  - lib/promiscuous/publisher/mongoid/defer_embedded.rb
145
137
  - lib/promiscuous/publisher/mongoid/embedded_many.rb
146
138
  - lib/promiscuous/publisher/mongoid/defer.rb
147
139
  - lib/promiscuous/publisher/polymorphic.rb
140
+ - lib/promiscuous/publisher/mock.rb
141
+ - lib/promiscuous/publisher/error.rb
148
142
  - lib/promiscuous/publisher/attributes.rb
149
143
  - lib/promiscuous/publisher/amqp.rb
150
- - lib/promiscuous/publisher/worker.rb
144
+ - lib/promiscuous/publisher/model.rb
145
+ - lib/promiscuous/publisher/active_record.rb
151
146
  - lib/promiscuous/publisher/base.rb
152
- - lib/promiscuous/publisher/mongoid.rb
153
147
  - lib/promiscuous/publisher/class.rb
154
- - lib/promiscuous/publisher/model.rb
148
+ - lib/promiscuous/publisher/ephemeral.rb
149
+ - lib/promiscuous/publisher/mongoid.rb
150
+ - lib/promiscuous/publisher/worker.rb
155
151
  - lib/promiscuous/railtie.rb
156
152
  - lib/promiscuous/railtie/replicate.rake
157
153
  - lib/promiscuous/subscriber/active_record.rb
@@ -159,27 +155,31 @@ files:
159
155
  - lib/promiscuous/subscriber/error.rb
160
156
  - lib/promiscuous/subscriber/lint.rb
161
157
  - lib/promiscuous/subscriber/lint/amqp.rb
162
- - lib/promiscuous/subscriber/lint/attributes.rb
163
158
  - lib/promiscuous/subscriber/lint/base.rb
164
159
  - lib/promiscuous/subscriber/lint/class.rb
165
160
  - lib/promiscuous/subscriber/lint/polymorphic.rb
166
- - lib/promiscuous/subscriber/mongoid/embedded.rb
161
+ - lib/promiscuous/subscriber/lint/attributes.rb
167
162
  - lib/promiscuous/subscriber/mongoid/embedded_many.rb
163
+ - lib/promiscuous/subscriber/mongoid/embedded.rb
168
164
  - lib/promiscuous/subscriber/mongoid/versioning.rb
165
+ - lib/promiscuous/subscriber/upsert.rb
169
166
  - lib/promiscuous/subscriber/observer.rb
170
167
  - lib/promiscuous/subscriber/polymorphic.rb
171
- - lib/promiscuous/subscriber/upsert.rb
172
168
  - lib/promiscuous/subscriber/amqp.rb
173
169
  - lib/promiscuous/subscriber/attributes.rb
174
- - lib/promiscuous/subscriber/base.rb
175
- - lib/promiscuous/subscriber/worker.rb
176
170
  - lib/promiscuous/subscriber/model.rb
171
+ - lib/promiscuous/subscriber/base.rb
177
172
  - lib/promiscuous/subscriber/class.rb
178
173
  - lib/promiscuous/subscriber/mongoid.rb
179
- - lib/promiscuous/subscriber.rb
180
- - lib/promiscuous/ephemeral.rb
174
+ - lib/promiscuous/subscriber/worker.rb
175
+ - lib/promiscuous/observer.rb
176
+ - lib/promiscuous/common.rb
177
+ - lib/promiscuous/config.rb
181
178
  - lib/promiscuous/amqp.rb
182
179
  - lib/promiscuous/worker.rb
180
+ - lib/promiscuous/ephemeral.rb
181
+ - lib/promiscuous/subscriber.rb
182
+ - lib/promiscuous/publisher.rb
183
183
  - lib/promiscuous/version.rb
184
184
  - lib/promiscuous.rb
185
185
  - README.md