sandthorn 1.2.0 → 1.3.0

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: 6972dfa7eb47e800f74d28d1680403c805bb8f81
4
- data.tar.gz: 5ff2d842c430fb11fe405f071698053163e943c6
3
+ metadata.gz: 321d7f4413f7f5f04220852b784f3abe1d0e27ff
4
+ data.tar.gz: fabd0afe1649aa90b909a930a4e61d90bc2e772d
5
5
  SHA512:
6
- metadata.gz: be7b451226e349e592599358cec26170fa32651b7b9cc27044a083a017b901ef5fe977b5c8e0673be89a167e99871538da1c4b90df32d088444e0f878f75bc5d
7
- data.tar.gz: f3d545cd1be566ec4870e625ef99cdaa95a78d986308339a329fb251c504399349da9867ba073518e1c83996cea7947cdc10d22c05e5d8b573f4d63fac895650
6
+ metadata.gz: e32ebc3a84466d2f9f7164e366446dc9ca8008bf6885b73165e9809bbac9f8dcaa8ec57633a367dd28f20b5b7a1fe63a80a1ebd79ae953c607e42159c320043e
7
+ data.tar.gz: 4a19b557e07fc383c8ac799a0fa157cf751ea7d01fd2740bd7253a33b36ee368700b44893df6ee5ec88d88327467a3e52e545b337079fe753574a352bde4ad9c
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ Gemfile.lock
19
19
  _yardoc
20
20
  doc/
21
21
  .idea
22
+ Dockerfile
data/README.md CHANGED
@@ -258,9 +258,6 @@ If there is a lot of events saved to an aggregate it can take some time to reloa
258
258
 
259
259
  There is one global snapshot store where all snapshots are stored independent on aggregate_type. To enable snapshot on a aggregate_type the Class has to be added to the `snapshot_types` Array when configuring Sandthorn. The aggregate will now be stored to the snapshot_store on every `.save` and when using `.find` it will look for a snapshot of the requested aggregate.
260
260
 
261
- Currently its only possible to store the snapshots in memory, so be careful not draining your applications memory space.
262
-
263
-
264
261
  ```ruby
265
262
 
266
263
  class Board
@@ -272,7 +269,7 @@ Sandthorn.configure do |c|
272
269
  end
273
270
  ```
274
271
 
275
- Its also possible to take manual snapshots without enabling snapshots on the aggregate_type.
272
+ Its possible to take manual snapshots without enabling snapshots on the aggregate_type.
276
273
 
277
274
  ```ruby
278
275
  board = Board.new
@@ -285,6 +282,22 @@ Sandthorn.save_snapshot board
285
282
  snapshot = Sandthorn.find_snapshot board.aggregate_id
286
283
  ```
287
284
 
285
+ ### External snapshot store
286
+
287
+ There is one external snapshot store available [sandthorn_snapshot_memcached](https://github.com/Sandthorn/sandthorn_snapshot_memcached) and it can be configured via `Sandthorn.configure`
288
+
289
+ ```ruby
290
+ require 'sandthorn_snapshot_memcached'
291
+
292
+ snapshot_store = SandthornSnapshotMemcached.from_url "memcached_url"
293
+
294
+ Sandthorn.configure do |conf|
295
+ conf.snapshot_store = snapshot_store
296
+ end
297
+ ```
298
+
299
+ **If no external snapshot store is configured snapshots will be stored in the application memory (be careful not draining your application memory space).**
300
+
288
301
  ## Bounded Context
289
302
 
290
303
  A bounded context is a system divider that split large systems into smaller parts. [Bounded Context by Martin Fowler](http://martinfowler.com/bliki/BoundedContext.html)
@@ -2,7 +2,7 @@ require "sandthorn/version"
2
2
  require "sandthorn/errors"
3
3
  require "sandthorn/aggregate_root"
4
4
  require "sandthorn/event_stores"
5
- require "sandthorn/snapshot_store"
5
+ require "sandthorn/application_snapshot_store"
6
6
  require 'yaml'
7
7
  require 'securerandom'
8
8
 
@@ -83,8 +83,8 @@ module Sandthorn
83
83
  @event_stores ||= EventStores.new
84
84
  end
85
85
 
86
- def event_store=(store)
87
- @event_stores = EventStores.new(store)
86
+ def event_store=(event_store)
87
+ @event_stores = EventStores.new(event_store)
88
88
  end
89
89
 
90
90
  def map_types= data
@@ -92,7 +92,11 @@ module Sandthorn
92
92
  end
93
93
 
94
94
  def snapshot_store
95
- @snapshot_store ||= SnapshotStore.new
95
+ @snapshot_store ||= ApplicationSnapshotStore.new
96
+ end
97
+
98
+ def snapshot_store=(snapshot_store)
99
+ @snapshot_store = snapshot_store
96
100
  end
97
101
 
98
102
  def snapshot_types= aggregate_types
@@ -0,0 +1,17 @@
1
+ module Sandthorn
2
+ class ApplicationSnapshotStore
3
+ def initialize
4
+ @store = Hash.new
5
+ end
6
+
7
+ attr_reader :store
8
+
9
+ def save aggregate_id, aggregate
10
+ @store[aggregate_id] = aggregate
11
+ end
12
+
13
+ def find aggregate_id
14
+ @store[aggregate_id]
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Sandthorn
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "autotest-standalone"
31
31
  spec.add_development_dependency "sqlite3"
32
32
  spec.add_development_dependency "coveralls"
33
- spec.add_development_dependency "sandthorn_driver_sequel", ">= 4.0"
33
+ spec.add_development_dependency "sandthorn_driver_sequel", "~> 4"
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandthorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Krantz
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-06-14 00:00:00.000000000 Z
13
+ date: 2018-07-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -156,16 +156,16 @@ dependencies:
156
156
  name: sandthorn_driver_sequel
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ">="
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
- version: '4.0'
161
+ version: '4'
162
162
  type: :development
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ">="
166
+ - - "~>"
167
167
  - !ruby/object:Gem::Version
168
- version: '4.0'
168
+ version: '4'
169
169
  description: Event sourcing
170
170
  email:
171
171
  - lars.krantz@alaz.se
@@ -189,11 +189,11 @@ files:
189
189
  - lib/sandthorn/aggregate_root.rb
190
190
  - lib/sandthorn/aggregate_root_base.rb
191
191
  - lib/sandthorn/aggregate_root_marshal.rb
192
+ - lib/sandthorn/application_snapshot_store.rb
192
193
  - lib/sandthorn/bounded_context.rb
193
194
  - lib/sandthorn/errors.rb
194
195
  - lib/sandthorn/event_inspector.rb
195
196
  - lib/sandthorn/event_stores.rb
196
- - lib/sandthorn/snapshot_store.rb
197
197
  - lib/sandthorn/version.rb
198
198
  - sandthorn.gemspec
199
199
  - spec/aggregate_delta_spec.rb
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.6.14
235
+ rubygems_version: 2.5.2.1
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Event sourcing gem
@@ -1,17 +0,0 @@
1
- module Sandthorn
2
- class SnapshotStore
3
- def initialize
4
- @store = Hash.new
5
- end
6
-
7
- attr_reader :store
8
-
9
- def save key, value
10
- @store[key] = value
11
- end
12
-
13
- def find key
14
- @store[key]
15
- end
16
- end
17
- end