evt-entity_snapshot-postgres 2.1.0.1 → 2.1.1.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 +4 -4
- data/lib/entity_snapshot/postgres/controls.rb +3 -0
- data/lib/entity_snapshot/postgres/controls/category.rb +26 -0
- data/lib/entity_snapshot/postgres/controls/entity_store.rb +4 -2
- data/lib/entity_snapshot/postgres/controls/id.rb +5 -1
- data/lib/entity_snapshot/postgres/controls/snapshot.rb +3 -5
- data/lib/entity_snapshot/postgres/controls/snapshot/read_only.rb +5 -1
- data/lib/entity_snapshot/postgres/controls/specifier.rb +7 -0
- data/lib/entity_snapshot/postgres/controls/subject.rb +22 -0
- data/lib/entity_snapshot/postgres/get.rb +7 -3
- data/lib/entity_snapshot/postgres/postgres.rb +3 -5
- data/lib/entity_snapshot/postgres/read_only.rb +1 -5
- data/lib/entity_snapshot/postgres/stream_name.rb +10 -2
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea3258c165ee43078715055211f13a28b0e21e3840acbb50991d9f18682884ec
|
4
|
+
data.tar.gz: 99884ffba8e79b6faa0f75bf43cd29f6370e8ece96a2f93af4ed6523e956d52e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22e5d56581dac816ca45b6deb2cf833187ece586d4e696a485b4dec907ed895be80ea772c6a85f3bd33d7e2bb799f991a60f898418ef1fec6a2ab585cc613c40
|
7
|
+
data.tar.gz: cb6d2a46f5f05d22fe48b69b6c4b15d812568cbf60cb1f19b2104c90abb625b8e0572241119c9a60f694021653b536183f0c0fc06ffb9357301d2456fef3b8a7
|
@@ -2,12 +2,15 @@ require 'entity_store/controls'
|
|
2
2
|
|
3
3
|
require 'entity_snapshot/postgres/controls/time'
|
4
4
|
require 'entity_snapshot/postgres/controls/id'
|
5
|
+
require 'entity_snapshot/postgres/controls/category'
|
5
6
|
require 'entity_snapshot/postgres/controls/stream_name'
|
6
7
|
require 'entity_snapshot/postgres/controls/version'
|
7
8
|
require 'entity_snapshot/postgres/controls/message'
|
8
9
|
require 'entity_snapshot/postgres/controls/batch'
|
9
10
|
require 'entity_snapshot/postgres/controls/entity'
|
10
11
|
require 'entity_snapshot/postgres/controls/random_value'
|
12
|
+
require 'entity_snapshot/postgres/controls/specifier'
|
13
|
+
require 'entity_snapshot/postgres/controls/subject'
|
11
14
|
require 'entity_snapshot/postgres/controls/snapshot'
|
12
15
|
require 'entity_snapshot/postgres/controls/snapshot/read_only'
|
13
16
|
require 'entity_snapshot/postgres/controls/snapshot/put'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module EntitySnapshot
|
2
|
+
class Postgres
|
3
|
+
module Controls
|
4
|
+
module Category
|
5
|
+
def self.example
|
6
|
+
"#{Type.example}:snapshot"
|
7
|
+
end
|
8
|
+
|
9
|
+
module Type
|
10
|
+
def self.example
|
11
|
+
'example'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
EntityPart = Type
|
15
|
+
|
16
|
+
module Specifier
|
17
|
+
def self.example(specifier=nil)
|
18
|
+
specifier ||= Controls::Specifier.example
|
19
|
+
|
20
|
+
"#{Type.example}#{specifier}:snapshot"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -2,12 +2,14 @@ module EntitySnapshot
|
|
2
2
|
class Postgres
|
3
3
|
module Controls
|
4
4
|
module EntityStore
|
5
|
-
def self.example(category: nil, entity_class: nil, projection_class: nil, snapshot_interval: nil)
|
5
|
+
def self.example(category: nil, entity_class: nil, specifier: nil, projection_class: nil, snapshot_interval: nil)
|
6
6
|
reader_class = MessageStore::Postgres::Read
|
7
7
|
snapshot_class = EntitySnapshot::Postgres
|
8
8
|
snapshot_interval ||= 2
|
9
9
|
category ||= 'example'
|
10
|
-
|
10
|
+
specifier ||= Specifier.example
|
11
|
+
|
12
|
+
::EntityStore::Controls::EntityStore.example(category: category, entity_class: entity_class, specifier: specifier, projection_class: projection_class, reader_class: reader_class, snapshot_class: snapshot_class, snapshot_interval: snapshot_interval)
|
11
13
|
end
|
12
14
|
|
13
15
|
module Assurance
|
@@ -2,12 +2,10 @@ module EntitySnapshot
|
|
2
2
|
class Postgres
|
3
3
|
module Controls
|
4
4
|
module Snapshot
|
5
|
-
def self.example
|
6
|
-
|
7
|
-
end
|
5
|
+
def self.example(specifier: nil)
|
6
|
+
subject = Subject.example(specifier: specifier)
|
8
7
|
|
9
|
-
|
10
|
-
Controls::Entity::Example
|
8
|
+
EntitySnapshot::Postgres.build(subject)
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
@@ -4,7 +4,11 @@ module EntitySnapshot
|
|
4
4
|
module Snapshot
|
5
5
|
module ReadOnly
|
6
6
|
def self.example
|
7
|
-
EntitySnapshot::Postgres::ReadOnly.build(
|
7
|
+
EntitySnapshot::Postgres::ReadOnly.build(subject)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.subject
|
11
|
+
Subject.example
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module EntitySnapshot
|
2
|
+
class Postgres
|
3
|
+
module Controls
|
4
|
+
module Subject
|
5
|
+
def self.example(entity_class: nil, specifier: nil, random: nil)
|
6
|
+
entity_class ||= self.entity_class
|
7
|
+
specifier ||= Specifier.example
|
8
|
+
|
9
|
+
::EntityCache::Controls::Subject.example(entity_class: entity_class, specifier: specifier, random: random)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.entity_class
|
13
|
+
Entity::Example
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.specifier
|
17
|
+
Specifier.example
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -7,15 +7,19 @@ module EntitySnapshot
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
def entity_class
|
11
|
+
subject.entity_class
|
12
|
+
end
|
13
|
+
|
10
14
|
def get(id)
|
11
15
|
stream_name = snapshot_stream_name(id)
|
12
16
|
|
13
|
-
logger.trace(tags: [:cache, :get]) { "Reading snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
|
17
|
+
logger.trace(tags: [:cache, :get]) { "Reading snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Specifier: #{subject.specifier || '(none)'})" }
|
14
18
|
|
15
19
|
event_data = read.(stream_name)
|
16
20
|
|
17
21
|
if event_data.nil?
|
18
|
-
logger.debug(tags: [:cache, :get, :missg]) { "No snapshot record (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name})" }
|
22
|
+
logger.debug(tags: [:cache, :get, :missg]) { "No snapshot record (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Specifier: #{subject.specifier || '(none)'})" }
|
19
23
|
return
|
20
24
|
end
|
21
25
|
|
@@ -36,7 +40,7 @@ module EntitySnapshot
|
|
36
40
|
time = Time.parse(time)
|
37
41
|
end
|
38
42
|
|
39
|
-
logger.debug(tags: [:cache, :get, :hit]) { "Read snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Version: #{version.inspect}, Time: #{time.utc.iso8601(3)})" }
|
43
|
+
logger.debug(tags: [:cache, :get, :hit]) { "Read snapshot (Stream: #{stream_name.inspect}, Entity Class: #{entity_class.name}, Specifier: #{subject.specifier || '(none)'}, Version: #{version.inspect}, Time: #{time.utc.iso8601(3)})" }
|
40
44
|
|
41
45
|
return entity, version, time
|
42
46
|
end
|
@@ -12,10 +12,8 @@ module EntitySnapshot
|
|
12
12
|
|
13
13
|
attr_accessor :session
|
14
14
|
|
15
|
-
alias_method :entity_class, :subject
|
16
|
-
|
17
15
|
def category
|
18
|
-
StreamName.category(
|
16
|
+
StreamName.category(entity_class, specifier)
|
19
17
|
end
|
20
18
|
|
21
19
|
def configure(session: nil)
|
@@ -25,8 +23,8 @@ module EntitySnapshot
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def put(id, entity, version, time)
|
28
|
-
unless entity.is_a?
|
29
|
-
error_msg = "Persistent storage for #{
|
26
|
+
unless entity.is_a?(entity_class)
|
27
|
+
error_msg = "Persistent storage for #{entity_class} cannot store #{entity}"
|
30
28
|
logger.error() { error_msg }
|
31
29
|
raise Error, error_msg
|
32
30
|
end
|
@@ -10,12 +10,8 @@ module EntitySnapshot
|
|
10
10
|
|
11
11
|
attr_accessor :session
|
12
12
|
|
13
|
-
alias_method :entity_class, :subject
|
14
|
-
|
15
13
|
def category
|
16
|
-
|
17
|
-
|
18
|
-
Casing::Camel.(entity_class_name)
|
14
|
+
StreamName.category(entity_class, specifier)
|
19
15
|
end
|
20
16
|
|
21
17
|
def configure(session: nil)
|
@@ -5,12 +5,20 @@ module EntitySnapshot
|
|
5
5
|
|
6
6
|
def snapshot_stream_name(id, category=nil)
|
7
7
|
category ||= self.category
|
8
|
+
|
8
9
|
Messaging::StreamName.stream_name(id, category, type: 'snapshot')
|
9
10
|
end
|
10
11
|
|
11
|
-
def self.category(entity_class)
|
12
|
+
def self.category(entity_class, specifier=nil)
|
12
13
|
*, entity_class_name = entity_class.name.split('::')
|
13
|
-
|
14
|
+
|
15
|
+
entity_class_name = Casing::Camel.(entity_class_name)
|
16
|
+
|
17
|
+
if specifier.nil?
|
18
|
+
entity_class_name
|
19
|
+
else
|
20
|
+
"#{entity_class_name}#{specifier}"
|
21
|
+
end
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
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: 2.1.0
|
4
|
+
version: 2.1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Eventide Project
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01
|
11
|
+
date: 2020-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-entity_store
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/entity_snapshot/postgres.rb
|
62
62
|
- lib/entity_snapshot/postgres/controls.rb
|
63
63
|
- lib/entity_snapshot/postgres/controls/batch.rb
|
64
|
+
- lib/entity_snapshot/postgres/controls/category.rb
|
64
65
|
- lib/entity_snapshot/postgres/controls/entity.rb
|
65
66
|
- lib/entity_snapshot/postgres/controls/entity_store.rb
|
66
67
|
- lib/entity_snapshot/postgres/controls/id.rb
|
@@ -69,7 +70,9 @@ files:
|
|
69
70
|
- lib/entity_snapshot/postgres/controls/snapshot.rb
|
70
71
|
- lib/entity_snapshot/postgres/controls/snapshot/put.rb
|
71
72
|
- lib/entity_snapshot/postgres/controls/snapshot/read_only.rb
|
73
|
+
- lib/entity_snapshot/postgres/controls/specifier.rb
|
72
74
|
- lib/entity_snapshot/postgres/controls/stream_name.rb
|
75
|
+
- lib/entity_snapshot/postgres/controls/subject.rb
|
73
76
|
- lib/entity_snapshot/postgres/controls/time.rb
|
74
77
|
- lib/entity_snapshot/postgres/controls/version.rb
|
75
78
|
- lib/entity_snapshot/postgres/controls/write.rb
|
@@ -82,7 +85,7 @@ homepage: https://github.com/eventide-project/entity-snapshot-postgres
|
|
82
85
|
licenses:
|
83
86
|
- MIT
|
84
87
|
metadata: {}
|
85
|
-
post_install_message:
|
88
|
+
post_install_message:
|
86
89
|
rdoc_options: []
|
87
90
|
require_paths:
|
88
91
|
- lib
|
@@ -97,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
100
|
- !ruby/object:Gem::Version
|
98
101
|
version: '0'
|
99
102
|
requirements: []
|
100
|
-
rubygems_version: 3.
|
101
|
-
signing_key:
|
103
|
+
rubygems_version: 3.1.2
|
104
|
+
signing_key:
|
102
105
|
specification_version: 4
|
103
106
|
summary: Projected entity snapshotting for Postgres
|
104
107
|
test_files: []
|