evt-message_store 1.1.0.1 → 2.3.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/message_store.rb +3 -1
- data/lib/message_store/controls.rb +1 -0
- data/lib/message_store/controls/category.rb +3 -1
- data/lib/message_store/controls/time.rb +22 -20
- data/lib/message_store/get/substitute.rb +1 -0
- data/lib/message_store/id.rb +45 -0
- data/lib/message_store/stream_name.rb +65 -22
- metadata +7 -8
- data/lib/message_store/postgres +0 -1
- data/lib/message_store/postgres.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0275af52a5677309393ba2fe0a1447042e32c9b586864eaba2b99b661f188607
|
4
|
+
data.tar.gz: f69ddf11f2594d75fdaa0711f099d0684bf2d240fd61a5cf76735f848ce91425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33d403b5079967fa053ed4cc74c49486ae7dd64166407cf26cfdc078d2524afa34ee67a0da085eae3468241d1c88eead55ad2ade6f0a3f5cf788d1a383173cba
|
7
|
+
data.tar.gz: 057bf4f68b0ca75f1f5cba5bbfe82b031c147e0f2ec2c24c368bf094db46183b54f9c176764b8d961680ce86f2c5d6100910a434748834f273f9958430dd7a5c
|
data/lib/message_store.rb
CHANGED
@@ -11,11 +11,13 @@ require 'async_invocation'
|
|
11
11
|
|
12
12
|
require 'message_store/expected_version'
|
13
13
|
require 'message_store/no_stream'
|
14
|
+
require 'message_store/id'
|
15
|
+
require 'message_store/stream_name'
|
16
|
+
|
14
17
|
require 'message_store/message_data'
|
15
18
|
require 'message_store/message_data/hash/transform'
|
16
19
|
require 'message_store/message_data/write'
|
17
20
|
require 'message_store/message_data/read'
|
18
|
-
require 'message_store/stream_name'
|
19
21
|
|
20
22
|
require 'message_store/log'
|
21
23
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module MessageStore
|
2
2
|
module Controls
|
3
3
|
module Category
|
4
|
-
def self.example(category: nil, randomize_category: nil)
|
4
|
+
def self.example(category: nil, type: nil, types: nil, randomize_category: nil)
|
5
5
|
if randomize_category.nil?
|
6
6
|
if !category.nil?
|
7
7
|
randomize_category = false
|
@@ -16,6 +16,8 @@ module MessageStore
|
|
16
16
|
category = "#{category}#{SecureRandom.hex(16)}XX"
|
17
17
|
end
|
18
18
|
|
19
|
+
category = Controls::StreamName.stream_name(category, type: type, types: types)
|
20
|
+
|
19
21
|
category
|
20
22
|
end
|
21
23
|
end
|
@@ -8,52 +8,54 @@ module MessageStore
|
|
8
8
|
|
9
9
|
module Raw
|
10
10
|
def self.example
|
11
|
-
|
12
|
-
Clock::UTC.now(time)
|
11
|
+
Clock::Controls::Time::Raw.example
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
module ISO8601
|
17
16
|
def self.example(time=nil)
|
18
|
-
|
19
|
-
|
17
|
+
Clock::Controls::Time::ISO8601.example(time)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.precision
|
21
|
+
3
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
module Processed
|
24
26
|
def self.example(time=nil, offset_milliseconds: nil)
|
25
|
-
|
26
|
-
|
27
|
-
ISO8601.example(time)
|
27
|
+
offset_milliseconds ||= self.offset_milliseconds
|
28
|
+
Clock::Controls::Time::Offset.example(offset_milliseconds, time: time, precision: ISO8601.precision)
|
28
29
|
end
|
29
30
|
|
30
31
|
module Raw
|
31
32
|
def self.example(time=nil, offset_milliseconds: nil)
|
32
|
-
|
33
|
-
offset_milliseconds
|
34
|
-
offset = Rational(offset_milliseconds, 1000)
|
35
|
-
time += offset
|
36
|
-
time
|
33
|
+
offset_milliseconds ||= Processed.offset_milliseconds
|
34
|
+
Clock::Controls::Time::Offset::Raw.example(offset_milliseconds, time: time, precision: ISO8601.precision)
|
37
35
|
end
|
38
36
|
end
|
37
|
+
|
38
|
+
def self.offset_milliseconds
|
39
|
+
11
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
module Effective
|
42
44
|
def self.example(time=nil, offset_milliseconds: nil)
|
43
|
-
|
44
|
-
|
45
|
-
ISO8601.example(time)
|
45
|
+
offset_milliseconds ||= self.offset_milliseconds
|
46
|
+
Clock::Controls::Time::Offset.example(offset_milliseconds, time: time, precision: ISO8601.precision)
|
46
47
|
end
|
47
48
|
|
48
49
|
module Raw
|
49
50
|
def self.example(time=nil, offset_milliseconds: nil)
|
50
|
-
|
51
|
-
offset_milliseconds
|
52
|
-
offset = Rational(offset_milliseconds, 1000)
|
53
|
-
time += offset
|
54
|
-
time
|
51
|
+
offset_milliseconds ||= Effective.offset_milliseconds
|
52
|
+
Clock::Controls::Time::Offset::Raw.example(offset_milliseconds, time: time, precision: ISO8601.precision)
|
55
53
|
end
|
56
54
|
end
|
55
|
+
|
56
|
+
def self.offset_milliseconds
|
57
|
+
1
|
58
|
+
end
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module MessageStore
|
2
|
+
module ID
|
3
|
+
Error = Class.new(RuntimeError)
|
4
|
+
|
5
|
+
def self.compound_id_separator
|
6
|
+
'+'
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.id(id)
|
10
|
+
if id.is_a?(Array)
|
11
|
+
id = compound_id(id)
|
12
|
+
else
|
13
|
+
if id.nil?
|
14
|
+
raise Error, "ID must not be omitted"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
id
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get(id)
|
22
|
+
id(id)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.compound_id(ids)
|
26
|
+
if ids.empty?
|
27
|
+
raise Error, "IDs must not be omitted"
|
28
|
+
end
|
29
|
+
|
30
|
+
ids.join(compound_id_separator)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.get_cardinal_id(id)
|
34
|
+
parse(id).first
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parse(id)
|
38
|
+
if id.nil?
|
39
|
+
raise Error, "ID must not be omitted"
|
40
|
+
end
|
41
|
+
|
42
|
+
id.split(compound_id_separator)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -2,70 +2,113 @@ module MessageStore
|
|
2
2
|
module StreamName
|
3
3
|
Error = Class.new(RuntimeError)
|
4
4
|
|
5
|
-
def self.
|
5
|
+
def self.id_separator
|
6
6
|
'-'
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.compound_id_separator
|
10
|
+
ID.compound_id_separator
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.category_type_separator
|
10
14
|
':'
|
11
15
|
end
|
12
16
|
|
13
|
-
def self.
|
17
|
+
def self.compound_type_separator
|
14
18
|
'+'
|
15
19
|
end
|
16
20
|
|
17
|
-
def self.stream_name(
|
18
|
-
if
|
19
|
-
raise Error, "Category
|
21
|
+
def self.stream_name(category, stream_id=nil, cardinal_id: nil, id: nil, ids: nil, type: nil, types: nil)
|
22
|
+
if category == nil
|
23
|
+
raise Error, "Category must not be omitted from stream name"
|
24
|
+
end
|
25
|
+
|
26
|
+
stream_name = category
|
27
|
+
|
28
|
+
type_list = []
|
29
|
+
type_list.concat(Array(type))
|
30
|
+
type_list.concat(Array(types))
|
31
|
+
|
32
|
+
type_part = type_list.join(compound_type_separator)
|
33
|
+
|
34
|
+
if not type_part.empty?
|
35
|
+
stream_name = "#{stream_name}#{category_type_separator}#{type_part}"
|
20
36
|
end
|
21
37
|
|
22
|
-
|
23
|
-
|
38
|
+
id_list = []
|
39
|
+
id_list << cardinal_id if not cardinal_id.nil?
|
24
40
|
|
25
|
-
|
26
|
-
|
41
|
+
id_list.concat(Array(stream_id))
|
42
|
+
id_list.concat(Array(id))
|
43
|
+
id_list.concat(Array(ids))
|
27
44
|
|
28
|
-
|
29
|
-
|
30
|
-
|
45
|
+
id_part = nil
|
46
|
+
if not id_list.empty?
|
47
|
+
id_part = ID.compound_id(id_list)
|
48
|
+
stream_name = "#{stream_name}#{id_separator}#{id_part}"
|
49
|
+
end
|
31
50
|
|
32
51
|
stream_name
|
33
52
|
end
|
34
53
|
|
35
54
|
def self.split(stream_name)
|
36
|
-
stream_name.split(
|
55
|
+
stream_name.split(id_separator, 2)
|
37
56
|
end
|
38
57
|
|
39
58
|
def self.get_id(stream_name)
|
40
59
|
split(stream_name)[1]
|
41
60
|
end
|
42
61
|
|
62
|
+
def self.get_ids(stream_name)
|
63
|
+
ids = get_id(stream_name)
|
64
|
+
|
65
|
+
return [] if ids.nil?
|
66
|
+
|
67
|
+
ID.parse(ids)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.get_cardinal_id(stream_name)
|
71
|
+
id = get_id(stream_name)
|
72
|
+
|
73
|
+
return nil if id.nil?
|
74
|
+
|
75
|
+
ID.get_cardinal_id(id)
|
76
|
+
end
|
77
|
+
|
43
78
|
def self.get_category(stream_name)
|
44
79
|
split(stream_name)[0]
|
45
80
|
end
|
46
81
|
|
47
82
|
def self.category?(stream_name)
|
48
|
-
!stream_name.include?(
|
83
|
+
!stream_name.include?(id_separator)
|
49
84
|
end
|
50
85
|
|
51
|
-
def self.
|
52
|
-
return nil unless stream_name.include?(
|
86
|
+
def self.get_category_type(stream_name)
|
87
|
+
return nil unless stream_name.include?(category_type_separator)
|
53
88
|
|
54
89
|
category = get_category(stream_name)
|
55
90
|
|
56
|
-
category.split(
|
91
|
+
category.split(category_type_separator)[1]
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.get_type(*args)
|
95
|
+
get_category_type(*args)
|
57
96
|
end
|
58
97
|
|
59
|
-
def self.
|
60
|
-
type_list =
|
98
|
+
def self.get_category_types(stream_name)
|
99
|
+
type_list = get_type(stream_name)
|
61
100
|
|
62
101
|
return [] if type_list.nil?
|
63
102
|
|
64
|
-
type_list.split(
|
103
|
+
type_list.split(compound_type_separator)
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.get_types(*args)
|
107
|
+
get_category_types(*args)
|
65
108
|
end
|
66
109
|
|
67
110
|
def self.get_entity_name(stream_name)
|
68
|
-
get_category(stream_name).split(
|
111
|
+
get_category(stream_name).split(category_type_separator)[0]
|
69
112
|
end
|
70
113
|
end
|
71
114
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evt-message_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.3.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:
|
11
|
+
date: 2021-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-casing
|
@@ -149,14 +149,13 @@ files:
|
|
149
149
|
- lib/message_store/get/stream/last.rb
|
150
150
|
- lib/message_store/get/stream/last/substitute.rb
|
151
151
|
- lib/message_store/get/substitute.rb
|
152
|
+
- lib/message_store/id.rb
|
152
153
|
- lib/message_store/log.rb
|
153
154
|
- lib/message_store/message_data.rb
|
154
155
|
- lib/message_store/message_data/hash/transform.rb
|
155
156
|
- lib/message_store/message_data/read.rb
|
156
157
|
- lib/message_store/message_data/write.rb
|
157
158
|
- lib/message_store/no_stream.rb
|
158
|
-
- lib/message_store/postgres
|
159
|
-
- lib/message_store/postgres.rb
|
160
159
|
- lib/message_store/read.rb
|
161
160
|
- lib/message_store/read/iterator.rb
|
162
161
|
- lib/message_store/stream_name.rb
|
@@ -165,7 +164,7 @@ homepage: https://github.com/eventide-project/message-store
|
|
165
164
|
licenses:
|
166
165
|
- MIT
|
167
166
|
metadata: {}
|
168
|
-
post_install_message:
|
167
|
+
post_install_message:
|
169
168
|
rdoc_options: []
|
170
169
|
require_paths:
|
171
170
|
- lib
|
@@ -180,8 +179,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
179
|
- !ruby/object:Gem::Version
|
181
180
|
version: '0'
|
182
181
|
requirements: []
|
183
|
-
rubygems_version: 3.
|
184
|
-
signing_key:
|
182
|
+
rubygems_version: 3.1.2
|
183
|
+
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Common primitives for platform-specific message store implementations
|
187
186
|
test_files: []
|
data/lib/message_store/postgres
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
lib/message_store/Users/sbellware/projects/eventide/message-store-postgres/lib/message_store/postgre
|
@@ -1 +0,0 @@
|
|
1
|
-
lib/message_store/Users/sbellware/projects/eventide/message-store-postgres/lib/message_store/postgre
|