eventus 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@ module Eventus
24
24
  @queue.set(key, "")
25
25
  end
26
26
  end
27
+ events
27
28
  end
28
29
 
29
30
  def load(id, min = nil)
@@ -29,6 +29,7 @@ module Eventus
29
29
  rescue ::Mongo::OperationFailure => e
30
30
  raise Eventus::ConcurrencyError if e.error_code == 11000
31
31
  end
32
+ doc
32
33
  end
33
34
 
34
35
  def load(id, min = nil)
@@ -48,16 +49,16 @@ module Eventus
48
49
  .sort_by{|e| e['sequence']}
49
50
  end
50
51
 
51
- def load_undispatched
52
- commits = @commits.find(dispatched: false).to_a
52
+ def load_undispatched_commits
53
+ commits = @commits.find(dispatched:false).to_a
53
54
  if commits.length > 0
54
55
  Eventus.logger.info "#{commits.length} undispatched commits loaded"
55
56
  end
56
57
  commits
57
58
  end
58
59
 
59
- def mark_dispatched(commit_id)
60
- Eventus.logger.debug "Marking #{commit_id} dispatched"
60
+ def mark_commit_dispatched(commit_id)
61
+ Eventus.logger.debug "Marking commit #{commit_id} dispatched"
61
62
  @commits.update({_id: commit_id}, {dispatched: true})
62
63
  end
63
64
 
@@ -26,9 +26,9 @@ module Eventus
26
26
  e['sequence'] = i
27
27
  end
28
28
  Eventus::logger.debug "Committing #{@uncommitted_events.length} events to #{@id}"
29
- @persistence.commit @uncommitted_events
29
+ payload = @persistence.commit @uncommitted_events
30
30
  load_events @uncommitted_events
31
- @dispatcher.dispatch @uncommitted_events if @dispatcher
31
+ @dispatcher.dispatch(payload) if @dispatcher
32
32
  @uncommitted_events.clear
33
33
  rescue ConcurrencyError => e
34
34
  Eventus.logger.info "ConcurrencyError, loading new events for: #{id}"
@@ -1,3 +1,3 @@
1
1
  module Eventus
2
- VERSION = "0.3.6"
2
+ VERSION = "0.3.7"
3
3
  end
@@ -5,7 +5,7 @@ describe Eventus::Persistence::Mongo do
5
5
  let(:uuid) { UUID.new }
6
6
 
7
7
  before(:all) do
8
- @persistence = Eventus::Persistence::Mongo.new('mongodb://localhost/test')
8
+ @persistence = Eventus::Persistence::Mongo.new(MONGO_URI)
9
9
  @persistence.db.collection('eventus_commits').drop
10
10
  end
11
11
 
@@ -50,13 +50,13 @@ describe Eventus::Persistence::Mongo do
50
50
  end
51
51
 
52
52
  it "should load undispatched events" do
53
- result = persistence.load_undispatched
53
+ result = persistence.load_undispatched_commits
54
54
  end
55
55
 
56
56
  it "should mark an event as dispatched" do
57
- result = persistence.load_undispatched[0]
58
- persistence.mark_dispatched(result['_id'])
59
- persistence.load_undispatched.any?{|c| c['_id'] == result['_id']}.should be_false
57
+ result = persistence.load_undispatched_commits[0]
58
+ persistence.mark_commit_dispatched(result['_id'])
59
+ persistence.load_undispatched_commits.include?(result).should be_false
60
60
  end
61
61
 
62
62
  it "should throw concurrency exception if the same event number is added" do
data/spec/spec_helper.rb CHANGED
@@ -7,6 +7,7 @@ require 'eventus'
7
7
  Bundler.require :development
8
8
 
9
9
  Dir[File.join(File.dirname(__FILE__), 'support', '*.rb')].each { |d| require d }
10
+ MONGO_URI = ENV['MONGO_URI'] || 'mongodb://localhost/test'
10
11
 
11
12
  RSpec.configure do |config|
12
13
  config.mock_with :rspec
data/spec/stream_spec.rb CHANGED
@@ -44,8 +44,9 @@ describe Eventus::Stream do
44
44
 
45
45
  describe "when committed" do
46
46
  before do
47
- persistence.should_receive(:commit)
48
- dispatcher.should_receive(:dispatch)
47
+ payload = {:truck => 'money'}
48
+ persistence.should_receive(:commit).and_return(payload)
49
+ dispatcher.should_receive(:dispatch).with(payload)
49
50
  stream.commit
50
51
  end
51
52
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-22 00:00:00.000000000 Z
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: An Event Store
15
15
  email: