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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2baec204d327357dfb307bed4653f6a956954733fd27c8cf69f06303394e71ab
4
- data.tar.gz: 599e1558fa244fa7ed0fd068559502cf234826ea40ac269c8f2a6385fa2475e2
3
+ metadata.gz: ea3258c165ee43078715055211f13a28b0e21e3840acbb50991d9f18682884ec
4
+ data.tar.gz: 99884ffba8e79b6faa0f75bf43cd29f6370e8ece96a2f93af4ed6523e956d52e
5
5
  SHA512:
6
- metadata.gz: c1b5978861c1492a4ef235f346049a0e0d50f1d70a3f7ec065228f7333ad682bd9d7cca8eeb780b3d0803990a74bfa7022e9bd45bce23dfe512ff1a5a9648ea2
7
- data.tar.gz: 9f93b3d17c5bd4cbc18fc9c32c95d380b0346834923719bd35860cd9844d2092f77a7b6de8bf24506f9d3f14e7b9b7c63c01d5dc25fed77227e255373f939314
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
- ::EntityStore::Controls::EntityStore.example(category: category, entity_class: entity_class, projection_class: projection_class, reader_class: reader_class, snapshot_class: snapshot_class, snapshot_interval: snapshot_interval)
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
@@ -1,7 +1,11 @@
1
1
  module EntitySnapshot
2
2
  class Postgres
3
3
  module Controls
4
- ID = EntityStore::Controls::ID
4
+ module ID
5
+ def self.example
6
+ Identifier::UUID::Controls::Random.example
7
+ end
8
+ end
5
9
  end
6
10
  end
7
11
  end
@@ -2,12 +2,10 @@ module EntitySnapshot
2
2
  class Postgres
3
3
  module Controls
4
4
  module Snapshot
5
- def self.example
6
- EntitySnapshot::Postgres.build(Controls::Entity::Example)
7
- end
5
+ def self.example(specifier: nil)
6
+ subject = Subject.example(specifier: specifier)
8
7
 
9
- def self.subject
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(Controls::Entity::Example)
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,7 @@
1
+ module EntitySnapshot
2
+ class Postgres
3
+ module Controls
4
+ Specifier = ::EntityStore::Controls::Specifier
5
+ end
6
+ end
7
+ 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(subject)
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? subject
29
- error_msg = "Persistent storage for #{subject} cannot store #{entity}"
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
- *, entity_class_name = entity_class.name.split('::')
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
- Casing::Camel.(entity_class_name)
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.1
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-16 00:00:00.000000000 Z
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.0.1
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: []