aggregate_streams 0.0.0.0 → 1.0.0.0.rc1

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: 7c87c67f4a3dfcf93d0e5ce30380844638a58dc4edfc1ed04d259d19bffc50c7
4
- data.tar.gz: ff1cbe61e2df7aa1da19f45202fcca08abe342f1ba1a9fa7b8d8cf9534762b23
3
+ metadata.gz: 18f3677271347279d2697fd882d26202f4de35f1b1a572f111f71215a3931796
4
+ data.tar.gz: 0044e3485e0b089b938312743894272bdaa7db5bc34d71140c2ec0ce35d7552b
5
5
  SHA512:
6
- metadata.gz: d05878e3d60552a37e307504c86fbc52ebe468700ac36431128782baf4765d1f31666125d4bd7f1b90fc61bbb6603ce062fe3c690fd87b6f619e89372a8b4251
7
- data.tar.gz: 0546551ec19669f9edbddb0e496a4424c08d3046b14037491daddfef08231256e8d6e644fec3f0498474fe4d934d1c8857bcbb2e28cc978bdb9d393fe9fe2f41
6
+ metadata.gz: d0fde2fec378bc68128cb6fd5408a9c9498c7a2d20b5bab72b6df16bbe3b54b7c1c643e2f98bb4f50428cffcaf2baf88654702d6075d62a62196aa40fd8916b4
7
+ data.tar.gz: 29d05a5f5ab4dbe717c1914a8134dc749bcd2aeb24867d4760c1dac30d6881fc94889a046ade1ce04e55042067e0c332c1bd5dfcd03fa5cc0861e9d828c1e2b1
@@ -1,35 +1,14 @@
1
1
  module AggregateStreams
2
2
  def self.start(input_categories, output_category, writer_session: nil, snapshot_interval: nil, **consumer_args, &transform_action)
3
- handler_block ||= proc { }
3
+ settings = {
4
+ :category => output_category,
5
+ :writer_session => writer_session,
6
+ :snapshot_interval => snapshot_interval,
7
+ :transform_action => transform_action
8
+ }
4
9
 
5
10
  input_categories.each do |input_category|
6
- handler_cls = Class.new do
7
- include Handle
8
-
9
- category output_category
10
-
11
- unless writer_session.nil?
12
- writer_session_macro do
13
- writer_session
14
- end
15
- end
16
-
17
- unless snapshot_interval.nil?
18
- snapshot_interval_macro snapshot_interval
19
- end
20
-
21
- unless transform_action.nil?
22
- transform(&transform_action)
23
- end
24
- end
25
-
26
- consumer_cls = Class.new do
27
- include Consumer
28
-
29
- handler handler_cls
30
- end
31
-
32
- consumer_cls.start(input_category, output_category: output_category, **consumer_args)
11
+ Consumer.start(input_category, output_category: output_category, supplemental_settings: settings, **consumer_args)
33
12
  end
34
13
  end
35
14
  end
@@ -1,25 +1,20 @@
1
1
  module AggregateStreams
2
- module Consumer
3
- def self.included(cls)
4
- cls.class_exec do
5
- include ::Consumer::Postgres
6
- include Configure
7
- end
8
- end
2
+ class Consumer
3
+ include ::Consumer::Postgres
4
+
5
+ handler Handle
9
6
 
10
- module Configure
11
- def configure(output_category:, output_session: nil, **args)
12
- super(**args)
7
+ def configure(output_category:, output_session: nil, **args)
8
+ super(**args)
13
9
 
14
- input_category = self.category
10
+ input_category = self.category
15
11
 
16
- PositionStore.configure(
17
- self,
18
- input_category,
19
- output_category,
20
- session: session
21
- )
22
- end
12
+ PositionStore.configure(
13
+ self,
14
+ input_category,
15
+ output_category,
16
+ session: output_session
17
+ )
23
18
  end
24
19
  end
25
20
  end
@@ -1,47 +1,24 @@
1
1
  module AggregateStreams
2
2
  module Controls
3
3
  module Handler
4
- def self.example(category: nil, snapshot: nil, snapshot_interval: nil, &specialize)
5
- if category.nil? && snapshot.nil? && snapshot_interval.nil? && specialize.nil?
6
- cls = Example
7
- else
8
- cls = example_class(category: category, snapshot: snapshot, snapshot_interval: snapshot_interval, &specialize)
9
- end
10
-
11
- cls.build
12
- end
13
-
14
- def self.example_class(category: nil, snapshot: nil, snapshot_interval: nil, &specialize)
4
+ def self.example(category: nil, snapshot: nil, snapshot_interval: nil, session: nil, writer_session: nil, &transform_action)
15
5
  if category == :none
16
6
  category = nil
17
7
  else
18
8
  category ||= Category.example
19
9
  end
20
10
 
21
- snapshot ||= false
11
+ settings_data = {}
22
12
 
23
- if snapshot
24
- snapshot_interval ||= Store.snapshot_interval
25
- end
26
-
27
- Class.new do
28
- include AggregateStreams::Handle
29
-
30
- unless category.nil?
31
- category category
32
- end
13
+ settings_data[:category] = category unless category.nil?
14
+ settings_data[:snapshot_interval] = snapshot_interval unless snapshot_interval.nil?
15
+ settings_data[:writer_session] = writer_session unless writer_session.nil?
16
+ settings_data[:transform_action] = transform_action unless transform_action.nil?
33
17
 
34
- unless snapshot_interval.nil?
35
- snapshot_interval snapshot_interval
36
- end
18
+ settings = Settings.build(settings_data)
37
19
 
38
- unless specialize.nil?
39
- class_exec(&specialize)
40
- end
41
- end
20
+ Handle.build(session: session, settings: settings)
42
21
  end
43
-
44
- Example = example_class
45
22
  end
46
23
  end
47
24
  end
@@ -1,40 +1,16 @@
1
1
  module AggregateStreams
2
2
  module Controls
3
3
  module Store
4
- def self.example(category: nil, snapshot: nil, snapshot_interval: nil)
5
- if category.nil? && snapshot.nil?
6
- cls = Example
7
- else
8
- cls = example_class(category: category, snapshot: snapshot, snapshot_interval: snapshot_interval)
9
- end
10
-
11
- cls.build
12
- end
13
-
14
- def self.example_class(category: nil, snapshot: nil, snapshot_interval: nil)
4
+ def self.example(category: nil, snapshot_interval: nil)
15
5
  if category == :none
16
6
  category = nil
17
7
  else
18
8
  category ||= self.category
19
9
  end
20
10
 
21
- snapshot ||= false
11
+ snapshot_interval ||= self.snapshot_interval
22
12
 
23
- if snapshot
24
- snapshot_interval ||= self.snapshot_interval
25
- end
26
-
27
- Class.new do
28
- include AggregateStreams::Store
29
-
30
- unless category.nil?
31
- category category
32
- end
33
-
34
- unless snapshot_interval.nil?
35
- snapshot EntitySnapshot::Postgres, interval: snapshot_interval
36
- end
37
- end
13
+ AggregateStreams::Store.build(category: category, snapshot_interval: snapshot_interval)
38
14
  end
39
15
 
40
16
  def self.category
@@ -44,8 +20,6 @@ module AggregateStreams
44
20
  def self.snapshot_interval
45
21
  11
46
22
  end
47
-
48
- Example = self.example_class
49
23
  end
50
24
  end
51
25
  end
@@ -1,33 +1,27 @@
1
1
  module AggregateStreams
2
- module Handle
3
- TransformError = Class.new(RuntimeError)
4
-
5
- def self.included(cls)
6
- cls.class_exec do
7
- include Messaging::Handle
8
- include Messaging::StreamName
2
+ class Handle
3
+ include Messaging::Handle
4
+ include Messaging::StreamName
9
5
 
10
- include Log::Dependency
6
+ include Log::Dependency
11
7
 
12
- prepend Configure
8
+ TransformError = Class.new(RuntimeError)
13
9
 
14
- extend StoreClass
15
- extend CategoryMacro
16
- extend TransformMacro
17
- extend SnapshotIntervalMacro
18
- extend WriterSessionMacro
10
+ setting :category
11
+ setting :snapshot_interval
12
+ setting :writer_session
13
+ setting :transform_action
19
14
 
20
- const_set :Store, store_class
15
+ dependency :store, Store
16
+ dependency :write, MessageStore::Postgres::Write
21
17
 
22
- dependency :store, self::Store
23
- dependency :write, MessageStore::Postgres::Write
18
+ def configure(session: nil)
19
+ writer_session = self.writer_session
20
+ writer_session ||= session
24
21
 
25
- virtual :writer_session
22
+ Store.configure(self, category: category, session: writer_session, snapshot_interval: snapshot_interval)
26
23
 
27
- virtual :transform_action do
28
- proc { |message_data| message_data }
29
- end
30
- end
24
+ MessageStore::Postgres::Write.configure(self, session: writer_session)
31
25
  end
32
26
 
33
27
  def handle(message_data)
@@ -84,7 +78,11 @@ module AggregateStreams
84
78
  end
85
79
 
86
80
  def transform(write_message_data, stream_name)
87
- transform_action.(write_message_data, stream_name)
81
+ if transform_action.nil?
82
+ write_message_data
83
+ else
84
+ transform_action.(write_message_data, stream_name)
85
+ end
88
86
  end
89
87
 
90
88
  def assure_message_data(message_data)
@@ -92,57 +90,5 @@ module AggregateStreams
92
90
  raise TransformError, "Not an instance of MessageData::Write"
93
91
  end
94
92
  end
95
-
96
- module Configure
97
- def configure(session: nil)
98
- writer_session = self.writer_session
99
- writer_session ||= session
100
-
101
- self.class::Store.configure(self, session: writer_session)
102
-
103
- MessageStore::Postgres::Write.configure(self, session: writer_session)
104
- end
105
- end
106
-
107
- module StoreClass
108
- def store_class
109
- @store_class ||= Class.new do
110
- include Store
111
- end
112
- end
113
- alias_method :store_cls, :store_class
114
- end
115
-
116
- module CategoryMacro
117
- def category_macro(category)
118
- super(category)
119
-
120
- store_class.category_macro(category)
121
- end
122
- alias_method :category, :category_macro
123
- end
124
-
125
- module TransformMacro
126
- def transform_macro(&transform_action)
127
- define_method(:transform_action) do
128
- transform_action
129
- end
130
- end
131
- alias_method :transform, :transform_macro
132
- end
133
-
134
- module SnapshotIntervalMacro
135
- def snapshot_interval_macro(interval)
136
- store_class.snapshot(EntitySnapshot::Postgres, interval: interval)
137
- end
138
- alias_method :snapshot_interval, :snapshot_interval_macro
139
- end
140
-
141
- module WriterSessionMacro
142
- def writer_session_macro(&block)
143
- define_method(:writer_session, &block)
144
- end
145
- alias_method :writer_session, :writer_session_macro
146
- end
147
93
  end
148
94
  end
@@ -1,19 +1,10 @@
1
1
  module AggregateStreams
2
- module Store
3
- def self.included(cls)
4
- cls.class_exec do
5
- include EntityStore
2
+ class Store
3
+ include EntityStore
6
4
 
7
- entity Aggregation
8
- projection Projection
9
- reader MessageStore::Postgres::Read, batch_size: Defaults.batch_size
10
- end
11
- end
12
-
13
- module Defaults
14
- def self.batch_size
15
- MessageStore::Postgres::Read::Defaults.batch_size
16
- end
17
- end
5
+ entity Aggregation
6
+ projection Projection
7
+ reader MessageStore::Postgres::Read
8
+ snapshot EntitySnapshot::Postgres, interval: 1000
18
9
  end
19
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggregate_streams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.0
4
+ version: 1.0.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Ladd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-consumer-postgres
@@ -132,9 +132,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
132
  version: '2.7'
133
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - ">="
135
+ - - ">"
136
136
  - !ruby/object:Gem::Version
137
- version: '0'
137
+ version: 1.3.1
138
138
  requirements: []
139
139
  rubygems_version: 3.1.4
140
140
  signing_key: