evt-entity_snapshot-postgres 0.2.2.3 → 0.2.3.0

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: '060299e1b3bd59dbd010162c93bb09b2a1502e92761393199b5ec2e16a406f84'
4
- data.tar.gz: f686d2cabb5000a28a8613841155c21e0d7cdd93f6394edee53043c7a6243393
3
+ metadata.gz: a4830021eb2636549b9ee6e4c57b8dcafe0c918e9de922e65f3159bc8becf7d7
4
+ data.tar.gz: e5cfa201fc1e1cf6c923788d0c47cd9fca7dc82421ce988258e1ce29a36bf00c
5
5
  SHA512:
6
- metadata.gz: 8af09e936e80f1b07e9978043c251a4c8a6000961903641feb973b0544f8b3bbdc2fd8f97c35d76b04e8a5fa1a77312dc51cb958a4af2b91bc59d947f261bc7c
7
- data.tar.gz: 0c6403b492d74c8325b574e078d9750b5ceae0f249751d2b9cfaf944bf4795aadb6cab06eba9897ca1b25cf0dbd7e0fcd4e41367ab6d6098cff60c7cd1eda202
6
+ metadata.gz: d65b464f31d3eed81d07884eba68387e2d434a3459b8ed2ff8229b81caf6936d1942a18870553fa7f152e00db61d53c221ec1f0b34758a5ba736842ce13fab03
7
+ data.tar.gz: d5f51acbd3de3b1b3b2fccb81b4e88fec018172ac8ce44d69c37ba1a02434ef9aea97cec7b39b75f3ac97b99595fd2ca0bb048c97722184fe5914bc603d9f1a5
@@ -0,0 +1,20 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ module Controls
4
+ module Snapshot
5
+ module Put
6
+ def self.call(id=nil, entity: nil, version: nil, time: nil)
7
+ id ||= ID.example
8
+ entity ||= Entity.example
9
+ version ||= Version.example
10
+ time ||= Time::Raw.example
11
+
12
+ snapshot = Snapshot.example
13
+
14
+ snapshot.put(id, entity, version, time)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ module Controls
4
+ module Snapshot
5
+ module ReadOnly
6
+ def self.example
7
+ EntitySnapshot::Postgres::ReadOnly.build(Controls::Entity::Example)
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -9,5 +9,7 @@ require 'entity_snapshot/postgres/controls/batch'
9
9
  require 'entity_snapshot/postgres/controls/entity'
10
10
  require 'entity_snapshot/postgres/controls/random_value'
11
11
  require 'entity_snapshot/postgres/controls/snapshot'
12
+ require 'entity_snapshot/postgres/controls/snapshot/read_only'
13
+ require 'entity_snapshot/postgres/controls/snapshot/put'
12
14
  require 'entity_snapshot/postgres/controls/write'
13
15
  require 'entity_snapshot/postgres/controls/entity_store'
@@ -0,0 +1,35 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ module Get
4
+ def self.prepended(cls)
5
+ cls.class_exec do
6
+ include StreamName
7
+ end
8
+ end
9
+
10
+ def get(id)
11
+ stream_name = snapshot_stream_name(id)
12
+
13
+ logger.trace(tags: [:snapshot, :cache, :get]) { "Reading snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
14
+
15
+ event_data = read.(stream_name)
16
+
17
+ if event_data.nil?
18
+ logger.debug(tags: [:snapshot, :cache, :get]) { "No snapshot record (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
19
+ return
20
+ end
21
+
22
+ entity_data = event_data.data[:entity_data]
23
+
24
+ entity = Transform::Read.instance(entity_data, entity_class)
25
+
26
+ version = event_data.data[:entity_version]
27
+ time = event_data.time
28
+
29
+ logger.debug(tags: [:snapshot, :cache, :get]) { "Read snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Version: #{version.inspect}, Time: #{time.utc.iso8601(3)})" }
30
+
31
+ return entity, version, time
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,8 +1,12 @@
1
1
  module EntitySnapshot
2
2
  class Postgres
3
3
  include Log::Dependency
4
+
5
+ prepend Get
4
6
  include EntityCache::Store::External
5
7
 
8
+ include StreamName
9
+
6
10
  dependency :write, MessageStore::Postgres::Put
7
11
  dependency :read, MessageStore::Postgres::Get::Last
8
12
 
@@ -10,11 +14,10 @@ module EntitySnapshot
10
14
 
11
15
  alias_method :entity_class, :subject
12
16
 
13
- def snapshot_stream_name(id)
14
- entity_class_name = entity_class.name.split('::').last
15
- entity_cateogry = Casing::Camel.(entity_class_name)
17
+ def category
18
+ *, entity_class_name = entity_class.name.split('::')
16
19
 
17
- Messaging::StreamName.stream_name(id, entity_cateogry, type: 'snapshot')
20
+ Casing::Camel.(entity_class_name)
18
21
  end
19
22
 
20
23
  def configure(session: nil)
@@ -53,30 +56,6 @@ module EntitySnapshot
53
56
  position
54
57
  end
55
58
 
56
- def get(id)
57
- stream_name = snapshot_stream_name(id)
58
-
59
- logger.trace(tags: [:snapshot, :cache, :get]) { "Reading snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
60
-
61
- event_data = read.(stream_name)
62
-
63
- if event_data.nil?
64
- logger.debug(tags: [:snapshot, :cache, :get]) { "No snapshot record (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
65
- return
66
- end
67
-
68
- entity_data = event_data.data[:entity_data]
69
-
70
- entity = Transform::Read.instance(entity_data, entity_class)
71
-
72
- version = event_data.data[:entity_version]
73
- time = event_data.time
74
-
75
- logger.debug(tags: [:snapshot, :cache, :get]) { "Read snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Version: #{version.inspect}, Time: #{time.utc.iso8601(3)})" }
76
-
77
- return entity, version, time
78
- end
79
-
80
59
  Error = Class.new(RuntimeError)
81
60
  end
82
61
  end
@@ -0,0 +1,30 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ class ReadOnly
4
+ include Log::Dependency
5
+
6
+ prepend Get
7
+ include EntityCache::Store::External
8
+
9
+ dependency :read, MessageStore::Postgres::Get::Last
10
+
11
+ attr_accessor :session
12
+
13
+ alias_method :entity_class, :subject
14
+
15
+ def category
16
+ *, entity_class_name = entity_class.name.split('::')
17
+
18
+ Casing::Camel.(entity_class_name)
19
+ end
20
+
21
+ def configure(session: nil)
22
+ MessageStore::Postgres::Session.configure(self, session: session)
23
+ MessageStore::Postgres::Get::Last.configure(self, session: self.session, attr_name: :read)
24
+ end
25
+
26
+ def put(*)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,17 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ module StreamName
4
+ extend self
5
+
6
+ def self.included(cls)
7
+ cls.class_exec do
8
+ include Messaging::StreamName
9
+ end
10
+ end
11
+
12
+ def snapshot_stream_name(id, category=nil)
13
+ stream_name(id, category, type: 'snapshot')
14
+ end
15
+ end
16
+ end
17
+ end
@@ -5,4 +5,10 @@ require 'entity_store'
5
5
 
6
6
  require 'entity_snapshot/postgres/log'
7
7
  require 'entity_snapshot/postgres/recorded'
8
+
9
+ require 'entity_snapshot/postgres/stream_name'
10
+
11
+ require 'entity_snapshot/postgres/get'
12
+
8
13
  require 'entity_snapshot/postgres/postgres'
14
+ require 'entity_snapshot/postgres/read_only'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-entity_snapshot-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2.3
4
+ version: 0.2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-16 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-entity_store
@@ -58,7 +58,6 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - lib/entity_snapshot/loader.rb
62
61
  - lib/entity_snapshot/postgres.rb
63
62
  - lib/entity_snapshot/postgres/controls.rb
64
63
  - lib/entity_snapshot/postgres/controls/batch.rb
@@ -68,13 +67,18 @@ files:
68
67
  - lib/entity_snapshot/postgres/controls/message.rb
69
68
  - lib/entity_snapshot/postgres/controls/random_value.rb
70
69
  - lib/entity_snapshot/postgres/controls/snapshot.rb
70
+ - lib/entity_snapshot/postgres/controls/snapshot/put.rb
71
+ - lib/entity_snapshot/postgres/controls/snapshot/read_only.rb
71
72
  - lib/entity_snapshot/postgres/controls/stream_name.rb
72
73
  - lib/entity_snapshot/postgres/controls/time.rb
73
74
  - lib/entity_snapshot/postgres/controls/version.rb
74
75
  - lib/entity_snapshot/postgres/controls/write.rb
76
+ - lib/entity_snapshot/postgres/get.rb
75
77
  - lib/entity_snapshot/postgres/log.rb
76
78
  - lib/entity_snapshot/postgres/postgres.rb
79
+ - lib/entity_snapshot/postgres/read_only.rb
77
80
  - lib/entity_snapshot/postgres/recorded.rb
81
+ - lib/entity_snapshot/postgres/stream_name.rb
78
82
  homepage: https://github.com/eventide-project/entity-snapshot-postgres
79
83
  licenses:
80
84
  - MIT
@@ -95,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
99
  version: '0'
96
100
  requirements: []
97
101
  rubyforge_project:
98
- rubygems_version: 2.7.3
102
+ rubygems_version: 2.7.6
99
103
  signing_key:
100
104
  specification_version: 4
101
105
  summary: Projected entity snapshotting for Postgres
@@ -1 +0,0 @@
1
- lib/entity_snapshot/postgres.rb