lib/ruote/storage/base.rb in ruote-2.1.6 vs lib/ruote/storage/base.rb in ruote-2.1.7
- old
+ new
@@ -53,16 +53,19 @@
def put_msg (action, options)
# merge! is way faster than merge (no object creation probably)
- t = Time.now
- t = "#{t.to_i}.#{"%06d" % t.usec}"
+ @counter ||= 0
- msg = options.merge!(
- 'type' => 'msgs',
- '_id' => "#{$$}-#{Thread.current.object_id}-#{t}",
- 'action' => action)
+ t = Time.now.utc
+ ts = "#{t.strftime('%Y-%m-%d')}!#{t.to_i}.#{'%06d' % t.usec}"
+ _id = "#{$$}!#{Thread.current.object_id}!#{ts}!#{'%03d' % @counter}"
+
+ @counter = (@counter + 1) % 1000
+ # some platforms (windows) have shallow usecs, so adding that counter...
+
+ msg = options.merge!('type' => 'msgs', '_id' => _id, 'action' => action)
msg.delete('_rev')
# in case of message replay
put(msg)