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 +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/README.md +7 -1
- data/Rakefile +4 -3
- data/lib/akasha/aggregate.rb +4 -3
- data/lib/akasha/async_event_router.rb +1 -1
- data/lib/akasha/changeset.rb +9 -4
- data/lib/akasha/storage/http_event_store/client.rb +1 -1
- data/lib/akasha/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43888ed8cfc9bef74f3fefe2cf10d20d19a38c648bd8b30ae40e4231b97ec9c4
|
4
|
+
data.tar.gz: 71f60f04b28b6d8bf954df421f686df8a8e2bdfa71e45416e57b2233f47d798a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e1dcef867875cd7415160eb5850719634d1045102c259645c3242a2d9df1f56d9866c54816586886c33069af49cfcb7639e745864e4475b7167cb7a97677baa
|
7
|
+
data.tar.gz: 52d8adb872e25e85c89647acdb2d2b1b45b8ece01e788c3702573fbfbe72e482fb843b82180d9d6877512807ede2cc4288f0f381bc2c5190de494263535d2e37
|
data/CHANGELOG.md
CHANGED
@@ -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
|
data/Gemfile.lock
CHANGED
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
|
-
|
13
|
-
|
14
|
-
|
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
|
|
data/lib/akasha/aggregate.rb
CHANGED
@@ -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
|
-
@
|
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
|
data/lib/akasha/changeset.rb
CHANGED
@@ -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 :
|
5
|
+
attr_reader :events
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
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:
|
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
|
|
data/lib/akasha/version.rb
CHANGED
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
|
+
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-
|
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:
|
265
|
+
version: 1.3.1
|
266
266
|
requirements: []
|
267
267
|
rubyforge_project:
|
268
268
|
rubygems_version: 2.7.7
|