rom-event_store 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66e28ad070bbb91cecc886f361871f203f52592f
4
- data.tar.gz: 9ef0b7b5c46512ea40e92a234dc15316aac0c9ba
3
+ metadata.gz: dd9b21f67358d6718d6f370b3189ec08aa06f037
4
+ data.tar.gz: 5fc12e375870ca09b599f9fd81d8ca4f0d20ca00
5
5
  SHA512:
6
- metadata.gz: 69de8603927a8fbe58d78fdf2115c987078a4fc18cb110e53d85c1a17f0b92d975cce459b03eae6a4e5812874d738e414cf72a7d2ca2c5c32f6ab651d4d9db54
7
- data.tar.gz: 1727f6546180fa12442d901140c277b0a226d9797912e2b18cf245478c52bbf1e682283778f2e22211436928dc1a31f4534e5c0e7db51f380c6a698c2edf11af
6
+ metadata.gz: a212f8ed1c9d145c23d47a303478a2869add9a178b9679429395e30d7529c2b9371a17c9b7ab53a202961291d2323ef058189274536840f742258069c5dbf411
7
+ data.tar.gz: 212c693398e13a6d502669c7c71490e1326f3a05cfefb7d7a677515c4f43ea4302d11c1e90ace27ffe943ed9af0d62926b8acbaa5acef15efe9c7ae5a8333dde
data/.travis.yml CHANGED
@@ -11,6 +11,8 @@ install:
11
11
  - "tar -xvzf EventStore-OSS-Linux-v3.0.3.tar.gz"
12
12
  - "mv EventStore-OSS-Linux-v3.0.3 .event_store"
13
13
  - "cd .event_store && ./run-node.sh --db ./ESData &"
14
+ - "sleep 5"
15
+ - "curl -X POST --user admin:changeit 'http://127.0.0.1:2113/projection/$by_category/command/enable' -H 'Content-Length: 0'"
14
16
  - "bundle install"
15
17
  script: "bundle exec rake ci"
16
18
  rvm:
data/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ ## v0.0.4 - 2015-04-05
2
+ ### Added
3
+ * Asynchronous subscriptions to relations (live and catchup)
4
+ * Partial reads from a relation (batch reads)
5
+ * TCP driver as an own gem: [estore](https://github.com/rom-eventstore/estore) (help wanted!!)
6
+ * `estore` gem updated (general refactoring and error handling improved. WIP)
7
+
8
+ [Compare v0.0.3...v0.0.4](https://github.com/rom-eventstore/rom-event_store/compare/v0.0.3...v0.0.4)
9
+
10
+ ## v0.0.3 - 2015-04-01
11
+ ### Added
12
+ * [TCP driver](https://github.com/mathieuravaux/eventstore-ruby) to connect and read events from the Event Store
13
+
14
+ [Compare v0.0.2...v0.0.3](https://github.com/rom-eventstore/rom-event_store/compare/v0.0.2...v0.0.3)
15
+
16
+ ## v0.0.2 - 2015-03-31
17
+ ### Added
18
+ * Relation through AtomPub API using HTTP
19
+ * Read all events from a relation
20
+ * Append events to a relation
21
+
22
+ [Compare v0.0.1...v0.0.2](https://github.com/rom-eventstore/rom-event_store/compare/v0.0.3...v0.0.4)
23
+
24
+ ## v0.0.1 - 2015-03-30
25
+ Initial release
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [inchpages]: http://inch-ci.org/github/rom-eventstore/rom-event_store
6
6
  [gitter]: https://gitter.im/rom-eventstore/rom-event_store?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
7
7
 
8
- # Rom::EventStore
8
+ # ROM::EventStore
9
9
 
10
10
  [![Gem Version](https://badge.fury.io/rb/rom-event_store.svg)][gem]
11
11
  [![Build Status](https://travis-ci.org/rom-eventstore/rom-event_store.svg?branch=master)][travis]
@@ -36,7 +36,7 @@ Or install it yourself as:
36
36
 
37
37
  ## Usage
38
38
 
39
- See [spec/integration/repository_spec.rb](spec/integration/repository_spec.rb) for a sample usage.
39
+ See [spec/integration/adapter_spec.rb](spec/integration/adapter_spec.rb) for a sample usage.
40
40
 
41
41
  ## License
42
42
 
@@ -0,0 +1 @@
1
+ require 'rom/event_store'
@@ -4,8 +4,8 @@ module ROM
4
4
  module EventStore
5
5
  module Commands
6
6
  class Append < ROM::Commands::Create
7
- def call(stream, *events)
8
- relation.from_stream(stream).append(events)
7
+ def execute(*events)
8
+ relation.append(events)
9
9
  end
10
10
  end
11
11
  end
@@ -1,48 +1,75 @@
1
1
  module ROM
2
2
  module EventStore
3
3
  class Dataset
4
- attr_reader :name
4
+ attr_reader :category
5
5
 
6
- def initialize(name, connection, options = {})
7
- @name = name
6
+ def initialize(category, connection, options = {})
7
+ @category = category
8
8
  @connection = connection
9
9
  @options = options
10
10
  end
11
11
 
12
- def from_stream(id)
13
- __new__(stream: id)
12
+ def select(stream)
13
+ __new__(stream: stream)
14
+ end
15
+
16
+ def from(id)
17
+ __new__(from: id)
18
+ end
19
+
20
+ def limit(limit)
21
+ __new__(limit: limit)
14
22
  end
15
23
 
16
24
  def stream
17
25
  stream = @options[:stream]
18
- stream ? "#{name}-#{stream}" : "$#{name}"
26
+ stream ? "#{category}-#{stream}" : "$ce-#{category}"
19
27
  end
20
28
 
21
29
  def events
22
- @connection.read(stream, option(:start, 0), option(:limit, 20))
30
+ @connection.read(stream, @options).sync
23
31
  end
24
32
 
25
33
  def append(events)
26
- @connection.append(stream, events)
34
+ @connection.append(stream, events).sync
35
+ events
36
+ end
37
+
38
+ def subscribe(&block)
39
+ subscription = @connection.subscription(stream, @options)
40
+ subscription.on_event(&block)
41
+ subscription.start
27
42
  end
28
43
 
29
44
  def each
30
- if block_given?
31
- events.each { |event| yield(event) }
32
- else
33
- to_enum
34
- end
45
+ with_events { |event| yield(event) }
35
46
  end
36
47
 
37
48
  private
38
49
 
39
50
  def __new__(new_opts = {})
40
- self.class.new(@name, @connection, @options.merge(new_opts))
51
+ self.class.new(@category, @connection, @options.merge(new_opts))
41
52
  end
42
53
 
43
54
  def option(option, default)
44
55
  @options.fetch(option, default)
45
56
  end
57
+
58
+ def with_events
59
+ events.each { |event| yield(dehydrate(event)) }
60
+ end
61
+
62
+ def dehydrate(wrapper)
63
+ event = wrapper.event
64
+
65
+ {
66
+ id: Estore::Package.parse_uuid(event.event_id),
67
+ type: event.event_type,
68
+ data: event.data,
69
+ number: event.event_number,
70
+ created_at: Time.at(event.created_epoch / 1000)
71
+ }
72
+ end
46
73
  end
47
74
  end
48
75
  end
@@ -3,7 +3,13 @@ require 'rom/relation'
3
3
  module ROM
4
4
  module EventStore
5
5
  class Relation < ROM::Relation
6
- forward :from_stream, :append
6
+ forward :select, :append, :subscribe, :from, :limit
7
+
8
+ def self.inherited(base)
9
+ super
10
+
11
+ base.exposed_relations.merge([:subscribe, :from, :limit])
12
+ end
7
13
  end
8
14
  end
9
15
  end
@@ -1,11 +1,11 @@
1
- require 'rom/event_store/connection'
1
+ require 'estore'
2
2
  require 'rom/event_store/dataset'
3
3
 
4
4
  module ROM
5
5
  module EventStore
6
6
  class Repository < ROM::Repository
7
7
  def initialize(uri)
8
- @connection = Connection.new(uri)
8
+ @connection = Estore::Session.new(*uri.split(':'))
9
9
  @categories = {}
10
10
  end
11
11
 
@@ -1,5 +1,5 @@
1
- module Rom
1
+ module ROM
2
2
  module EventStore
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ require 'rom/event_store/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'rom-event_store'
8
- spec.version = Rom::EventStore::VERSION
8
+ spec.version = ROM::EventStore::VERSION
9
9
  spec.authors = ['Héctor Ramón', 'Lorenzo Arribas']
10
10
  spec.email = ['hector0193@gmail.com', 'lorenzo.s.arribas@gmail.com']
11
11
 
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.add_runtime_dependency 'rom', '~> 0.6'
23
- spec.add_runtime_dependency 'estore', '~> 0.0.2'
23
+ spec.add_runtime_dependency 'estore', '~> 0.1.1'
24
24
 
25
25
  spec.add_development_dependency 'bundler'
26
- spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
27
  spec.add_development_dependency 'rubocop', '~> 0.28.0'
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-event_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Héctor Ramón
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-04-01 00:00:00.000000000 Z
12
+ date: 2015-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rom
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.0.2
34
+ version: 0.1.1
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.0.2
41
+ version: 0.1.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bundler
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -57,16 +57,16 @@ dependencies:
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ">="
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0'
62
+ version: '10.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0'
69
+ version: '10.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rubocop
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -93,13 +93,14 @@ files:
93
93
  - ".rubocop.yml"
94
94
  - ".rubocop_todo.yml"
95
95
  - ".travis.yml"
96
+ - CHANGELOG.md
96
97
  - Gemfile
97
98
  - LICENSE
98
99
  - README.md
99
100
  - Rakefile
101
+ - lib/rom-event_store.rb
100
102
  - lib/rom/event_store.rb
101
103
  - lib/rom/event_store/commands.rb
102
- - lib/rom/event_store/connection.rb
103
104
  - lib/rom/event_store/dataset.rb
104
105
  - lib/rom/event_store/relation.rb
105
106
  - lib/rom/event_store/repository.rb
@@ -1,36 +0,0 @@
1
- require 'estore'
2
- require 'json'
3
-
4
- module ROM
5
- module EventStore
6
- class Connection
7
- def initialize(uri)
8
- host_port = uri.split(':')
9
- @connection = Estore::Session.new(*host_port)
10
- end
11
-
12
- def read(stream, start, limit)
13
- read = @connection.read(stream, start, limit)
14
- read.sync.events.map { |event| dehydrate(event) }
15
- end
16
-
17
- def append(stream, events)
18
- @connection.append(stream, events).sync
19
- end
20
-
21
- private
22
-
23
- def dehydrate(wrapper)
24
- event = wrapper.event
25
-
26
- {
27
- id: Estore::Package.parse_uuid(event.event_id),
28
- type: event.event_type,
29
- data: event.data,
30
- number: event.event_number,
31
- created_at: Time.at(event.created_epoch / 1000)
32
- }
33
- end
34
- end
35
- end
36
- end