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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f11bc763f84ee7713a149dcbd82c93a05c3bd6bc77ccf6238f3eddff404547ab
4
- data.tar.gz: 58a75a34e87d818aed83f73bfe446a0435ba6dbc6e7266cb4a0230878d81cc62
3
+ metadata.gz: cb4d8995c7708ce060d8ff40fcd223b6867fb78aa3e6d3fd8c2de22c5a5fe08b
4
+ data.tar.gz: 732951ca371e4d92ad5681ecf2c7c26f7ac53f2076c50ebfe7b16d3f75a13484
5
5
  SHA512:
6
- metadata.gz: c4b2f5af783cbc5dd299bcd6c00072dfa2c8da0c34917f10967714a694cb872bd2186cfeb580b8886454e39b0bbf2cf3da0fb648945bec8d965752a261a8770d
7
- data.tar.gz: 81e9df220c30010d3fe1863d521b2407940f674005c00569763b0e8da6fbbf8bace91cc06a9e2e55ff7bea6f1bee28d6351ed4c3d7ed5268b00afa7a5638cccd
6
+ metadata.gz: 4c2c039b57d9f148863a09aaa5df67f64cda57d8a7014dcc060bcf90336bc716e83dde4dc3dfa7d735975b651276683aafbe9d132368771d5a4d528fcabdb223
7
+ data.tar.gz: 911ce0c2080f1134d29bfd1ace3b6217909de1529cd94b3c310d9abf1982a224986dd8c96a3caaf1b4e142cd7ef41e403bcd759f817491ce51a03f54ed256609
@@ -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,5 +1,6 @@
1
1
  require 'securerandom'
2
2
 
3
+ require 'clock/controls'
3
4
  require 'identifier/uuid/controls'
4
5
 
5
6
  require 'message_store/controls/random_value'
@@ -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
- time = ::Time.parse("Jan 1 00:00:00 UTC 2000")
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
- time ||= Raw.example
19
- Clock::UTC.iso8601(time)
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
- time ||= Time::Raw.example
26
- time = Raw.example(time, offset_milliseconds: offset_milliseconds)
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
- time ||= Time::Raw.example
33
- offset_milliseconds ||= 11
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
- time ||= Time::Raw.example
44
- time = Raw.example(time, offset_milliseconds: offset_milliseconds)
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
- time ||= Time::Raw.example
51
- offset_milliseconds ||= 1
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
@@ -7,6 +7,7 @@ module MessageStore
7
7
  include Get
8
8
 
9
9
  attr_accessor :stream_name
10
+ alias :category :stream_name
10
11
 
11
12
  def batch_size
12
13
  @batch_size ||= 1
@@ -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.id_delimiter
5
+ def self.id_separator
6
6
  '-'
7
7
  end
8
8
 
9
- def self.category_delimiter
10
- ':'
9
+ def self.compound_id_separator
10
+ ID.compound_id_separator
11
11
  end
12
12
 
13
- def self.type_delimiter
14
- '+'
13
+ def self.category_type_separator
14
+ ':'
15
15
  end
16
16
 
17
- class << self
18
- alias :compound_id_delimiter :type_delimiter
17
+ def self.compound_type_separator
18
+ '+'
19
19
  end
20
20
 
21
- def self.stream_name(category_name, id=nil, type: nil, types: nil)
22
- if category_name == nil
23
- raise Error, "Category name must not be omitted from stream name"
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
- types = Array(types)
27
- types.unshift(type) unless type.nil?
26
+ stream_name = category
28
27
 
29
- type_list = nil
30
- type_list = types.join(type_delimiter) unless types.empty?
28
+ type_list = []
29
+ type_list.concat(Array(type))
30
+ type_list.concat(Array(types))
31
31
 
32
- stream_name = category_name
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 id.nil?
36
- if id.is_a?(Array)
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
- stream_name = "#{stream_name}#{id_delimiter}#{id}" unless id.nil?
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(id_delimiter, 2)
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
- ids.split(compound_id_delimiter)
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?(id_delimiter)
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?(category_delimiter)
87
+ return nil unless stream_name.include?(category_type_separator)
72
88
 
73
89
  category = get_category(stream_name)
74
90
 
75
- category.split(category_delimiter)[1]
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(type_delimiter)
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(category_delimiter)[0]
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: 1.2.0.0
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: 2019-11-03 00:00:00.000000000 Z
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.0.1
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: []
@@ -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