tcb 0.5.0 → 0.6.1
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/CHANGELOG.md +40 -1
- data/README.md +290 -133
- data/lib/generators/tcb/domain/domain_generator.rb +1 -1
- data/lib/generators/tcb/event_store/event_store_generator.rb +1 -1
- data/lib/generators/tcb/event_store/templates/migration.rb.tt +11 -7
- data/lib/generators/tcb/install/install_generator.rb +1 -1
- data/lib/generators/tcb/install/templates/tcb.rb.tt +12 -10
- data/lib/tcb/command_bus.rb +5 -1
- data/lib/tcb/configuration.rb +13 -7
- data/lib/tcb/correlation_query.rb +32 -0
- data/lib/tcb/envelope.rb +31 -0
- data/lib/tcb/event_bus/queue_pressure_monitor.rb +35 -0
- data/lib/tcb/event_bus/running_strategy.rb +32 -2
- data/lib/tcb/event_bus/shutdown_strategy.rb +4 -0
- data/lib/tcb/event_bus.rb +40 -38
- data/lib/tcb/event_bus_queue_pressure.rb +10 -0
- data/lib/tcb/event_store/active_record.rb +69 -19
- data/lib/tcb/event_store/in_memory.rb +17 -7
- data/lib/tcb/publish.rb +7 -4
- data/lib/tcb/record.rb +47 -11
- data/lib/tcb/test_helpers/shared.rb +2 -2
- data/lib/tcb/version.rb +1 -1
- data/lib/tcb.rb +44 -11
- metadata +6 -3
- data/lib/tcb/event_store/event_stream_envelope.rb +0 -13
data/lib/tcb/version.rb
CHANGED
data/lib/tcb.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "tcb/envelope"
|
|
3
4
|
require_relative "tcb/minitest_helpers"
|
|
4
5
|
require_relative "tcb/domain_context"
|
|
6
|
+
require_relative "tcb/correlation_query"
|
|
5
7
|
require_relative "tcb/event_query"
|
|
6
8
|
require_relative "tcb/event_store/active_record"
|
|
7
|
-
require_relative "tcb/event_store/event_stream_envelope"
|
|
8
9
|
require_relative "tcb/event_store/in_memory"
|
|
9
10
|
require_relative "tcb/stream_id"
|
|
10
11
|
require_relative "tcb/handles_events"
|
|
@@ -16,13 +17,29 @@ require_relative "tcb/publish"
|
|
|
16
17
|
require_relative "tcb/command_bus"
|
|
17
18
|
require_relative "tcb/subscriber_metadata_extractor"
|
|
18
19
|
require_relative "tcb/subscriber_invocation_failed"
|
|
20
|
+
require_relative "tcb/event_bus/queue_pressure_monitor"
|
|
21
|
+
require_relative "tcb/event_bus_queue_pressure"
|
|
19
22
|
require_relative "tcb/event_bus_shutdown"
|
|
20
23
|
require_relative "tcb/domain"
|
|
21
24
|
require_relative "tcb/event_bus"
|
|
22
25
|
require_relative "tcb/version"
|
|
23
26
|
|
|
24
27
|
module TCB
|
|
25
|
-
|
|
28
|
+
|
|
29
|
+
def self.domain_modules=(modules)
|
|
30
|
+
@domain_modules = modules
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.domain_modules
|
|
34
|
+
@domain_modules || []
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.configure(&block)
|
|
38
|
+
yield config
|
|
39
|
+
config.domain_modules = @domain_modules || []
|
|
40
|
+
config.permitted_serialization_classes
|
|
41
|
+
config.freeze
|
|
42
|
+
end
|
|
26
43
|
|
|
27
44
|
def self.record(events_from: [], events: [], within: nil, &block)
|
|
28
45
|
Record.call(
|
|
@@ -42,16 +59,32 @@ module TCB
|
|
|
42
59
|
)
|
|
43
60
|
end
|
|
44
61
|
|
|
45
|
-
def self.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
def self.read_correlation(correlation_id, across: nil)
|
|
63
|
+
domains = across || config.domain_modules.select do |m|
|
|
64
|
+
m.respond_to?(:persist_registrations) && m.persist_registrations.any?
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
CorrelationQuery.new(
|
|
68
|
+
store: config.event_store,
|
|
69
|
+
correlation_id: correlation_id,
|
|
70
|
+
domains: domains
|
|
71
|
+
)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def self.config
|
|
75
|
+
@config ||= Configuration.new
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def self.configured?
|
|
79
|
+
!!@config && @config.event_bus_configured?
|
|
50
80
|
end
|
|
51
81
|
|
|
52
|
-
def self.reset!
|
|
53
|
-
|
|
82
|
+
def self.reset!(graceful_shutdown_time: nil)
|
|
83
|
+
if configured?
|
|
84
|
+
graceful_shutdown_time ?
|
|
85
|
+
@config.event_bus.shutdown(drain: true, timeout: graceful_shutdown_time) :
|
|
86
|
+
@config.event_bus.force_shutdown
|
|
87
|
+
end
|
|
54
88
|
@config = nil
|
|
55
|
-
configure(&@configure_block) if @configure_block
|
|
56
89
|
end
|
|
57
|
-
end
|
|
90
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tcb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ljubomir Marković
|
|
@@ -145,17 +145,20 @@ files:
|
|
|
145
145
|
- lib/tcb.rb
|
|
146
146
|
- lib/tcb/command_bus.rb
|
|
147
147
|
- lib/tcb/configuration.rb
|
|
148
|
+
- lib/tcb/correlation_query.rb
|
|
148
149
|
- lib/tcb/domain.rb
|
|
149
150
|
- lib/tcb/domain_context.rb
|
|
151
|
+
- lib/tcb/envelope.rb
|
|
150
152
|
- lib/tcb/event_bus.rb
|
|
153
|
+
- lib/tcb/event_bus/queue_pressure_monitor.rb
|
|
151
154
|
- lib/tcb/event_bus/running_strategy.rb
|
|
152
155
|
- lib/tcb/event_bus/shutdown_strategy.rb
|
|
153
156
|
- lib/tcb/event_bus/subscriber_registry.rb
|
|
154
157
|
- lib/tcb/event_bus/termination_signal_handler.rb
|
|
158
|
+
- lib/tcb/event_bus_queue_pressure.rb
|
|
155
159
|
- lib/tcb/event_bus_shutdown.rb
|
|
156
160
|
- lib/tcb/event_query.rb
|
|
157
161
|
- lib/tcb/event_store/active_record.rb
|
|
158
|
-
- lib/tcb/event_store/event_stream_envelope.rb
|
|
159
162
|
- lib/tcb/event_store/in_memory.rb
|
|
160
163
|
- lib/tcb/handles_commands.rb
|
|
161
164
|
- lib/tcb/handles_events.rb
|
|
@@ -174,7 +177,7 @@ licenses:
|
|
|
174
177
|
- MIT
|
|
175
178
|
metadata:
|
|
176
179
|
source_code_uri: https://github.com/tcb-si/tcb
|
|
177
|
-
changelog_uri: https://github.com/tcb-si/tcb/blob/
|
|
180
|
+
changelog_uri: https://github.com/tcb-si/tcb/blob/master/CHANGELOG.md
|
|
178
181
|
rdoc_options: []
|
|
179
182
|
require_paths:
|
|
180
183
|
- lib
|