evt-message_store 1.1.0.0 → 2.3.0.2

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: 40121815466711f7a023e49b5c02c8439456ef0eff75171a2ba0f56513358774
4
- data.tar.gz: 4d3ce500d096eb4b877722b8dd6052cc6bcb8f7f7b90bba124453272e07a1d9c
3
+ metadata.gz: 10704ac2544b2ef44429b0e55c4c44ccc78fe460c141b1927997b00d7d2dea75
4
+ data.tar.gz: b217d7aa1b18943f71cfb8c450c3820da418ec6c465acfe23c02cf948563a925
5
5
  SHA512:
6
- metadata.gz: edeac71d9c4a5d8abcea0d48e6598007b05d88760a58fc62bd456a146f84f33383e15ce179415705d404639c1db9d14812409fc86fa6ebd51318cef65915ae58
7
- data.tar.gz: 1c3d8ae0f92318f2742e9649595110d0fa777058b9f46ba1ffcf77b0304d9bf95224ed054d8938535b9f37519d2589bd7eb6bc79d46a9bc6be0aed7a6fe5f521
6
+ metadata.gz: a898788cd605db367f529f2f750899b40cf164908ee8297c0e3e3e092c246953704a2021be8a25c5b9ace959b14a82536184f641228b6845cb7a49ee3ba2730c
7
+ data.tar.gz: 0272bc2fe2995e8448ccaee0e452037782a03581c0b77844233d27eaec2614971c2625959409c68b273a2027df7609a683ffb52ab21e179b41e075f0ed8203d0
@@ -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
@@ -70,6 +70,7 @@ module MessageStore
70
70
  message_data = iterator.next
71
71
 
72
72
  break if message_data.nil?
73
+ logger.debug(tags: [:data, :message_data]) { message_data.pretty_inspect }
73
74
 
74
75
  action.(message_data)
75
76
  end
@@ -2,70 +2,113 @@ 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
9
+ def self.compound_id_separator
10
+ '+'
11
+ end
12
+
13
+ def self.category_type_separator
10
14
  ':'
11
15
  end
12
16
 
13
- def self.type_delimiter
17
+ def self.compound_type_separator
14
18
  '+'
15
19
  end
16
20
 
17
- def self.stream_name(category_name, id=nil, type: nil, types: nil)
18
- if category_name == nil
19
- 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"
20
24
  end
21
25
 
22
- types = Array(types)
23
- types.unshift(type) unless type.nil?
26
+ stream_name = category
24
27
 
25
- type_list = nil
26
- 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
+
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}"
36
+ end
27
37
 
28
- stream_name = category_name
29
- stream_name = "#{stream_name}#{category_delimiter}#{type_list}" unless type_list.nil?
30
- 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 = id_list.join(compound_id_separator)
46
+
47
+ if not id_part.empty?
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(id_delimiter, 2)
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
+ ids.split(compound_id_separator)
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.split(compound_id_separator).first
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?(id_delimiter)
83
+ !stream_name.include?(id_separator)
49
84
  end
50
85
 
51
- def self.get_type_list(stream_name)
52
- return nil unless stream_name.include?(category_delimiter)
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(category_delimiter)[1]
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.get_types(stream_name)
60
- type_list = get_type_list(stream_name)
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(type_delimiter)
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(category_delimiter)[0]
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: 1.1.0.0
4
+ version: 2.3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-02 00:00:00.000000000 Z
11
+ date: 2020-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-casing
@@ -155,8 +155,6 @@ files:
155
155
  - lib/message_store/message_data/read.rb
156
156
  - lib/message_store/message_data/write.rb
157
157
  - lib/message_store/no_stream.rb
158
- - lib/message_store/postgres
159
- - lib/message_store/postgres.rb
160
158
  - lib/message_store/read.rb
161
159
  - lib/message_store/read/iterator.rb
162
160
  - lib/message_store/stream_name.rb
@@ -180,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
178
  - !ruby/object:Gem::Version
181
179
  version: '0'
182
180
  requirements: []
183
- rubygems_version: 3.0.1
181
+ rubygems_version: 3.1.2
184
182
  signing_key:
185
183
  specification_version: 4
186
184
  summary: Common primitives for platform-specific message store implementations
@@ -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