evt-message_store 1.2.0.0 → 2.3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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 +41 -0
- data/lib/message_store/stream_name.rb +44 -28
- 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: cb4d8995c7708ce060d8ff40fcd223b6867fb78aa3e6d3fd8c2de22c5a5fe08b
|
4
|
+
data.tar.gz: 732951ca371e4d92ad5681ecf2c7c26f7ac53f2076c50ebfe7b16d3f75a13484
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2c039b57d9f148863a09aaa5df67f64cda57d8a7014dcc060bcf90336bc716e83dde4dc3dfa7d735975b651276683aafbe9d132368771d5a4d528fcabdb223
|
7
|
+
data.tar.gz: 911ce0c2080f1134d29bfd1ace3b6217909de1529cd94b3c310d9abf1982a224986dd8c96a3caaf1b4e142cd7ef41e403bcd759f817491ce51a03f54ed256609
|
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,41 @@
|
|
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.compound_id(ids)
|
22
|
+
if ids.empty?
|
23
|
+
raise Error, "IDs must not be omitted"
|
24
|
+
end
|
25
|
+
|
26
|
+
ids.join(compound_id_separator)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.get_cardinal_id(id)
|
30
|
+
parse(id).first
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.parse(id)
|
34
|
+
if id.nil?
|
35
|
+
raise Error, "ID must not be omitted"
|
36
|
+
end
|
37
|
+
|
38
|
+
id.split(compound_id_separator)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -2,49 +2,57 @@ 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.
|
10
|
-
|
9
|
+
def self.compound_id_separator
|
10
|
+
ID.compound_id_separator
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.
|
14
|
-
'
|
13
|
+
def self.category_type_separator
|
14
|
+
':'
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
def self.compound_type_separator
|
18
|
+
'+'
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.stream_name(
|
22
|
-
if
|
23
|
-
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
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
types.unshift(type) unless type.nil?
|
26
|
+
stream_name = category
|
28
27
|
|
29
|
-
type_list =
|
30
|
-
type_list
|
28
|
+
type_list = []
|
29
|
+
type_list.concat(Array(type))
|
30
|
+
type_list.concat(Array(types))
|
31
31
|
|
32
|
-
|
33
|
-
stream_name = "#{stream_name}#{category_delimiter}#{type_list}" unless type_list.nil?
|
32
|
+
type_part = type_list.join(compound_type_separator)
|
34
33
|
|
35
|
-
if not
|
36
|
-
|
37
|
-
id = id.join(compound_id_delimiter)
|
38
|
-
end
|
34
|
+
if not type_part.empty?
|
35
|
+
stream_name = "#{stream_name}#{category_type_separator}#{type_part}"
|
39
36
|
end
|
40
37
|
|
41
|
-
|
38
|
+
id_list = []
|
39
|
+
id_list << cardinal_id if not cardinal_id.nil?
|
40
|
+
|
41
|
+
id_list.concat(Array(stream_id))
|
42
|
+
id_list.concat(Array(id))
|
43
|
+
id_list.concat(Array(ids))
|
44
|
+
|
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
|
42
50
|
|
43
51
|
stream_name
|
44
52
|
end
|
45
53
|
|
46
54
|
def self.split(stream_name)
|
47
|
-
stream_name.split(
|
55
|
+
stream_name.split(id_separator, 2)
|
48
56
|
end
|
49
57
|
|
50
58
|
def self.get_id(stream_name)
|
@@ -56,7 +64,15 @@ module MessageStore
|
|
56
64
|
|
57
65
|
return [] if ids.nil?
|
58
66
|
|
59
|
-
|
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)
|
60
76
|
end
|
61
77
|
|
62
78
|
def self.get_category(stream_name)
|
@@ -64,15 +80,15 @@ module MessageStore
|
|
64
80
|
end
|
65
81
|
|
66
82
|
def self.category?(stream_name)
|
67
|
-
!stream_name.include?(
|
83
|
+
!stream_name.include?(id_separator)
|
68
84
|
end
|
69
85
|
|
70
86
|
def self.get_category_type(stream_name)
|
71
|
-
return nil unless stream_name.include?(
|
87
|
+
return nil unless stream_name.include?(category_type_separator)
|
72
88
|
|
73
89
|
category = get_category(stream_name)
|
74
90
|
|
75
|
-
category.split(
|
91
|
+
category.split(category_type_separator)[1]
|
76
92
|
end
|
77
93
|
|
78
94
|
def self.get_type(*args)
|
@@ -84,7 +100,7 @@ module MessageStore
|
|
84
100
|
|
85
101
|
return [] if type_list.nil?
|
86
102
|
|
87
|
-
type_list.split(
|
103
|
+
type_list.split(compound_type_separator)
|
88
104
|
end
|
89
105
|
|
90
106
|
def self.get_types(*args)
|
@@ -92,7 +108,7 @@ module MessageStore
|
|
92
108
|
end
|
93
109
|
|
94
110
|
def self.get_entity_name(stream_name)
|
95
|
-
get_category(stream_name).split(
|
111
|
+
get_category(stream_name).split(category_type_separator)[0]
|
96
112
|
end
|
97
113
|
end
|
98
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.1
|
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
|