estore 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.simplecov +12 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +11 -4
- data/Gemfile +1 -0
- data/lib/estore/commands/reads/forward.rb +1 -1
- data/lib/estore/commands/subscription.rb +13 -3
- data/lib/estore/commands/subscriptions/catch_up.rb +7 -13
- data/lib/estore/commands/subscriptions/live.rb +1 -1
- data/lib/estore/connection.rb +1 -3
- data/lib/estore/connection_context.rb +3 -0
- data/lib/estore/errors.rb +1 -0
- data/lib/estore/version.rb +1 -1
- data/spec/integration/session_spec.rb +22 -0
- data/spec/unit/estore/connection_context_spec.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ec9eb805fb44a8772c81a4f5ea5bfd4d224779
|
4
|
+
data.tar.gz: d29629f1fdb5f8819b0204becf1d1a97934f0ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3896eeed05e045d57d635d467d9b002f5394b2b7f0a76f192d4bb0009e4c760d1b94fa60ce093ffbef483eab4a42c3d9bf52a2901e8a46d89eceba58c83e742b
|
7
|
+
data.tar.gz: 81a42f181c7541577a950b74d7a23824259c0cf31b20ac385ddbca91e58ed2d31cca791c127066024f2508a5173d39af6ae381f1bf0a2a30fc247b3c6489a6f3
|
data/.simplecov
CHANGED
@@ -7,8 +7,18 @@ SimpleCov.start do
|
|
7
7
|
add_filter '/config/'
|
8
8
|
|
9
9
|
require 'coveralls'
|
10
|
+
|
11
|
+
formatters = [
|
12
|
+
SimpleCov::Formatter::HTMLFormatter,
|
13
|
+
Coveralls::SimpleCov::Formatter
|
14
|
+
]
|
15
|
+
|
16
|
+
if RUBY_ENGINE == 'rbx'
|
17
|
+
require 'codeclimate-test-reporter'
|
18
|
+
formatters << CodeClimate::TestReporter::Formatter
|
19
|
+
end
|
20
|
+
|
10
21
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
11
|
-
|
12
|
-
SimpleCov::Formatter::HTMLFormatter
|
22
|
+
*formatters
|
13
23
|
]
|
14
24
|
end
|
data/.travis.yml
CHANGED
@@ -10,7 +10,7 @@ install:
|
|
10
10
|
- "wget -nc http://download.geteventstore.com/binaries/EventStore-OSS-Linux-v3.0.3.tar.gz"
|
11
11
|
- "tar -xvzf EventStore-OSS-Linux-v3.0.3.tar.gz"
|
12
12
|
- "mv EventStore-OSS-Linux-v3.0.3 .event_store"
|
13
|
-
- "cd .event_store && ./run-node.sh --db
|
13
|
+
- "cd .event_store && ./run-node.sh --mem-db &"
|
14
14
|
- "bundle install"
|
15
15
|
script: "bundle exec rake ci"
|
16
16
|
rvm:
|
data/CHANGELOG.md
CHANGED
@@ -1,28 +1,35 @@
|
|
1
|
+
## v0.1.3 - 2015-04-15
|
2
|
+
### Added
|
3
|
+
* Workers to dispatch events in subscriptions
|
4
|
+
* Print error information while dispatching
|
5
|
+
|
6
|
+
[Compare v0.1.2...v0.1.3](https://github.com/eventstore-rb/estore/compare/v0.1.2...v0.1.3)
|
7
|
+
|
1
8
|
## v0.1.2 - 2015-04-05
|
2
9
|
### Added
|
3
10
|
* Errors during commands reject promises too
|
4
11
|
* Unit testing started
|
5
12
|
|
6
|
-
[Compare v0.1.1...v0.1.2](https://github.com/
|
13
|
+
[Compare v0.1.1...v0.1.2](https://github.com/eventstore-rb/estore/compare/v0.1.1...v0.1.2)
|
7
14
|
|
8
15
|
## v0.1.1 - 2015-04-05
|
9
16
|
### Added
|
10
17
|
* General errors during connection reject command promises
|
11
18
|
|
12
|
-
[Compare v0.1.0...v0.1.1](https://github.com/
|
19
|
+
[Compare v0.1.0...v0.1.1](https://github.com/eventstore-rb/estore/compare/v0.1.0...v0.1.1)
|
13
20
|
|
14
21
|
## v0.1.0 - 2015-04-03
|
15
22
|
### Added
|
16
23
|
* General refactoring using the concept of `Command`
|
17
24
|
|
18
|
-
[Compare v0.0.2...v0.1.0](https://github.com/
|
25
|
+
[Compare v0.0.2...v0.1.0](https://github.com/eventstore-rb/estore/compare/v0.0.2...v0.1.0)
|
19
26
|
|
20
27
|
## v0.0.2 - 2015-04-01
|
21
28
|
### Added
|
22
29
|
* Gem name changed to `estore`
|
23
30
|
* Minor refactoring
|
24
31
|
|
25
|
-
[Compare v0.0.1...v0.0.2](https://github.com/
|
32
|
+
[Compare v0.0.1...v0.0.2](https://github.com/eventstore-rb/estore/compare/v0.0.1...v0.0.2)
|
26
33
|
|
27
34
|
## v0.0.1 - 2015-03-31
|
28
35
|
Forked from [eventstore-ruby](https://github.com/mathieuravaux/eventstore-ruby)
|
data/Gemfile
CHANGED
@@ -6,6 +6,8 @@ module Estore
|
|
6
6
|
@has_finished = false
|
7
7
|
@stream = stream
|
8
8
|
@resolve_link_tos = options.fetch(:resolve_link_tos, true)
|
9
|
+
@worker_queue = Queue.new
|
10
|
+
@worker = Thread.new { loop { worker_loop } }
|
9
11
|
end
|
10
12
|
|
11
13
|
def call
|
@@ -33,9 +35,17 @@ module Estore
|
|
33
35
|
@handler = block
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
|
38
|
-
@
|
38
|
+
def enqueue(events)
|
39
|
+
events = Array(events)
|
40
|
+
@position = events.last.original_event_number
|
41
|
+
@worker_queue << events
|
42
|
+
end
|
43
|
+
|
44
|
+
def worker_loop
|
45
|
+
@worker_queue.pop.each { |event| @handler.call(event) }
|
46
|
+
rescue => e
|
47
|
+
puts e.message
|
48
|
+
puts e.backtrace
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
@@ -12,9 +12,8 @@ module Estore
|
|
12
12
|
@from = from
|
13
13
|
@batch = options[:batch_size]
|
14
14
|
@mutex = Mutex.new
|
15
|
-
@
|
15
|
+
@while_catching_up = []
|
16
16
|
@caught_up = false
|
17
|
-
@last_worker = nil
|
18
17
|
end
|
19
18
|
|
20
19
|
def start
|
@@ -22,37 +21,32 @@ module Estore
|
|
22
21
|
|
23
22
|
# TODO: Think about doing something more clever?
|
24
23
|
read = ReadForward.new(@connection, @stream, @from, @batch) do |events|
|
25
|
-
|
26
|
-
last_worker.join if last_worker
|
27
|
-
events.each { |event| dispatch(event) }
|
28
|
-
end
|
24
|
+
enqueue events unless events.empty?
|
29
25
|
end
|
30
26
|
|
31
27
|
read.call.sync
|
32
|
-
@last_worker.join if @last_worker
|
33
|
-
|
34
28
|
switch_to_live
|
35
29
|
end
|
36
30
|
|
37
31
|
def switch_to_live
|
38
32
|
@mutex.synchronize do
|
39
|
-
|
33
|
+
unprocessed_events.each { |event| enqueue event }
|
40
34
|
@caught_up = true
|
41
35
|
end
|
42
36
|
end
|
43
37
|
|
44
|
-
def
|
45
|
-
@
|
38
|
+
def unprocessed_events
|
39
|
+
@while_catching_up.find_all { |event| event.original_event_number > @position }
|
46
40
|
end
|
47
41
|
|
48
42
|
def event_appeared(response)
|
49
43
|
unless @caught_up
|
50
44
|
@mutex.synchronize do
|
51
|
-
@
|
45
|
+
@while_catching_up << response.event unless @caught_up
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
55
|
-
|
49
|
+
enqueue response.event if @caught_up
|
56
50
|
end
|
57
51
|
end
|
58
52
|
end
|
data/lib/estore/connection.rb
CHANGED
@@ -56,9 +56,7 @@ module Estore
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def process_downstream
|
59
|
-
loop
|
60
|
-
@buffer << socket.sysread(4096)
|
61
|
-
end
|
59
|
+
loop { @buffer << socket.sysread(4096) }
|
62
60
|
rescue IOError, EOFError
|
63
61
|
@context.on_error(DisconnectionError.new) unless @terminating
|
64
62
|
rescue => error
|
data/lib/estore/errors.rb
CHANGED
data/lib/estore/version.rb
CHANGED
@@ -108,4 +108,26 @@ describe Estore::Session do
|
|
108
108
|
|
109
109
|
expect(received).to have(2130).events.starting_at(30).before(20.seconds)
|
110
110
|
end
|
111
|
+
|
112
|
+
it 'allows to make a catchup subscription to a non-existing stream' do
|
113
|
+
stream = random_stream
|
114
|
+
received = []
|
115
|
+
|
116
|
+
sub = session.subscription(stream, from: 0)
|
117
|
+
|
118
|
+
sub.on_event do |event|
|
119
|
+
received << event
|
120
|
+
puts "Receiving... #{received.size}"
|
121
|
+
end
|
122
|
+
|
123
|
+
sub.start
|
124
|
+
|
125
|
+
Thread.new do
|
126
|
+
30.times do
|
127
|
+
stream_with(2, stream)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
expect(received).to have(60).events.starting_at(0).before(20.seconds)
|
132
|
+
end
|
111
133
|
end
|
@@ -3,8 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe Estore::ConnectionContext do
|
4
4
|
subject(:context) { Estore::ConnectionContext.new }
|
5
5
|
|
6
|
-
let(:
|
7
|
-
|
6
|
+
let(:bad_command_class) do
|
7
|
+
Class.new do
|
8
8
|
attr_reader :error
|
9
9
|
|
10
10
|
def uuid
|
@@ -19,10 +19,10 @@ describe Estore::ConnectionContext do
|
|
19
19
|
boom
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
BadCommand.new
|
24
22
|
end
|
25
23
|
|
24
|
+
let(:bad_command) { bad_command_class.new }
|
25
|
+
|
26
26
|
before do
|
27
27
|
context.register(bad_command)
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: estore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Ravaux
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beefcake
|