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.
data/lib/tcb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TCB
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.1"
5
5
  end
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
- Envelope = EventStore::EventStreamEnvelope
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.configure(&block)
46
- @configure_block = block
47
- yield config
48
- config.permitted_serialization_classes
49
- config.freeze
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
- @config.event_bus.force_shutdown
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.5.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/main/CHANGELOG.md
180
+ changelog_uri: https://github.com/tcb-si/tcb/blob/master/CHANGELOG.md
178
181
  rdoc_options: []
179
182
  require_paths:
180
183
  - lib
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TCB
4
- class EventStore
5
- EventStreamEnvelope = Data.define(
6
- :event,
7
- :event_id,
8
- :stream_id,
9
- :version,
10
- :occurred_at
11
- )
12
- end
13
- end