akasha 0.4.0 → 0.5.0.pre1.214

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 705a0bd652b156fe253d9084255e16f31e691ecb72a1feb0db5a258c138f2ee0
4
- data.tar.gz: 6913586f6b2fbf5e23fe61a67007d570cdcc1aaafa896a1dbc9364e9d7126088
3
+ metadata.gz: 43888ed8cfc9bef74f3fefe2cf10d20d19a38c648bd8b30ae40e4231b97ec9c4
4
+ data.tar.gz: 71f60f04b28b6d8bf954df421f686df8a8e2bdfa71e45416e57b2233f47d798a
5
5
  SHA512:
6
- metadata.gz: 5656d456264ae24606d1040333d5eaae48bb2b74543e04c6c59bb893ab65f9515c53f892d0ca6cd3cb67e6543c1d3fd4fbce3e80672e36822da4015616fb384e
7
- data.tar.gz: 192e285039e9f84ea10356e43e000cbb716230b1cd0a9b6feeb21a27f0495533f274507ff23d6ab5e92920eadde0dbaf402de499d60cd96a337d5eb1ff47118c
6
+ metadata.gz: 5e1dcef867875cd7415160eb5850719634d1045102c259645c3242a2d9df1f56d9866c54816586886c33069af49cfcb7639e745864e4475b7167cb7a97677baa
7
+ data.tar.gz: 52d8adb872e25e85c89647acdb2d2b1b45b8ece01e788c3702573fbfbe72e482fb843b82180d9d6877512807ede2cc4288f0f381bc2c5190de494263535d2e37
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.5.0
4
+
5
+ * Apply changeset when command is executed to update the aggregate's state.
6
+
7
+ * Fix events applied in reverse order when reading from Eventstore.
8
+
9
+
3
10
  ## Version 0.4.0
4
11
 
5
12
  * Support for optimistic concurrency for commands. Enabled by default, will raise `ConflictError` if the aggregate
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- akasha (0.4.0)
4
+ akasha (0.5.0.pre1)
5
5
  corefines (~> 1.11)
6
6
  faraday (~> 0.15)
7
7
  faraday_middleware
data/README.md CHANGED
@@ -65,7 +65,13 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
65
65
 
66
66
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
67
67
 
68
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
68
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). While on a branch, add ".pre" to the version number.
69
+
70
+ Release rules:
71
+
72
+ 1. All merges to master build & push gems and git tags with versions.
73
+ 2. If `version.rb` is pre-release version, e.g. `4.0.0.pre`, Travis will automatically append the build number and push it.
74
+ 3. If `version.rb` is a regular version, e.g. `5.0.0`, Travis will not append build number. (I haven't tested it yet.)
69
75
 
70
76
 
71
77
  ## Running tests
data/Rakefile CHANGED
@@ -9,9 +9,10 @@ namespace 'ci' do
9
9
  spec_path = gemspecs.first
10
10
  gemspec = Bundler.load_gemspec(spec_path)
11
11
  version_tag = "v#{gemspec.version}"
12
- return if `git tag`.split(/\n/).include?(version_tag)
13
- puts "Tagging with tag #{version_tag}"
14
- `git tag #{version_tag}`
12
+ unless `git tag`.split(/\n/).include?(version_tag)
13
+ puts "Tagging with tag #{version_tag}"
14
+ `git tag #{version_tag}`
15
+ end
15
16
  end
16
17
  end
17
18
 
@@ -19,11 +19,12 @@ module Akasha
19
19
  class Aggregate
20
20
  include SyntaxHelpers
21
21
 
22
- attr_reader :changeset, :revision
22
+ attr_reader :id, :changeset, :revision
23
23
 
24
24
  def initialize(id)
25
25
  @revision = -1 # No stream exists.
26
- @changeset = Changeset.new(id)
26
+ @id = id
27
+ @changeset = Changeset.new(self)
27
28
  end
28
29
 
29
30
  # Replay events, building up the state of the aggregate.
@@ -33,7 +34,7 @@ module Akasha
33
34
  method_name = event_handler(event)
34
35
  public_send(method_name, event.data) if respond_to?(method_name)
35
36
  end
36
- @revision = events.last&.revision.to_i
37
+ @revision = events.last&.revision.to_i if events.last.respond_to?(:revision)
37
38
  end
38
39
 
39
40
  private
@@ -42,7 +42,7 @@ module Akasha
42
42
  end
43
43
  end
44
44
  end
45
- rescue RutimeError => e
45
+ rescue RuntimeError => e
46
46
  puts e # TODO: Decide on a strategy.
47
47
  raise
48
48
  end
@@ -2,17 +2,22 @@ module Akasha
2
2
  # Represents changes to an aggregate, for example an array of
3
3
  # events generated when handling a command.
4
4
  class Changeset
5
- attr_reader :aggregate_id, :events
5
+ attr_reader :events
6
6
 
7
- def initialize(aggregate_id)
8
- @aggregate_id = aggregate_id
7
+ def initialize(aggregate)
8
+ @aggregate = aggregate
9
9
  @events = []
10
10
  end
11
11
 
12
+ def aggregate_id
13
+ @aggregate.id
14
+ end
15
+
12
16
  # Adds an event to the changeset.
13
17
  def append(event_name, **data)
14
18
  id = SecureRandom.uuid
15
- event = Akasha::Event.new(event_name, id, { aggregate_id: @aggregate_id }, **data)
19
+ event = Akasha::Event.new(event_name, id, { aggregate_id: aggregate_id }, **data)
20
+ @aggregate.apply_events([event])
16
21
  @events << event
17
22
  end
18
23
 
@@ -135,7 +135,7 @@ module Akasha
135
135
  req.headers['ES-LongPoll'] = poll if poll&.positive?
136
136
  req.params['embed'] = 'body'
137
137
  end
138
- to_events(resp.body['entries'])
138
+ to_events(resp.body['entries']).reverse!
139
139
  end || []
140
140
  end
141
141
 
@@ -1,3 +1,3 @@
1
1
  module Akasha
2
- VERSION = '0.4.0'.freeze
2
+ VERSION = '0.5.0.pre1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akasha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0.pre1.214
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcin Bilski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-04 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: corefines
@@ -260,9 +260,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
260
  version: '0'
261
261
  required_rubygems_version: !ruby/object:Gem::Requirement
262
262
  requirements:
263
- - - ">="
263
+ - - ">"
264
264
  - !ruby/object:Gem::Version
265
- version: '0'
265
+ version: 1.3.1
266
266
  requirements: []
267
267
  rubyforge_project:
268
268
  rubygems_version: 2.7.7