cdc-concurrent 0.0.0 → 0.1.0
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 +22 -3
- data/lib/cdc/concurrent/configuration.rb +6 -2
- data/lib/cdc/concurrent/processor_extensions.rb +1 -1
- data/lib/cdc/concurrent/processor_pool.rb +8 -1
- data/lib/cdc/concurrent/version.rb +1 -1
- data/sig/cdc/concurrent/configuration.rbs +7 -1
- data/sig/cdc/concurrent/processor_pool.rbs +2 -0
- data/sig/shims/async.rbs +20 -0
- data/sig/shims/cdc_core.rbs +31 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbc0a0ebe15a9254e91b40caa48db7f7f26e4b01933be88e5fd148ea8c3371d0
|
|
4
|
+
data.tar.gz: 38888cc8ade72e4611e352fa534a25876cbc71d6ef74c2f725b5bb3ef1c4c069
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3315531e5f0cbe43f86461acabf835ec5f187d65dace206d1640a213b42702a0ee8e1088421f1e2f05e076ce9dfcdd7625f309f837b613c5f13dfc459b07152
|
|
7
|
+
data.tar.gz: 351566c71b92c033c2c35b2639653eabf6e75d3bacee667f643dde9af47bffaf7dbeee4f802eb8e237bd5e9a5bc7957d43269b323fc9c17b89bedda1ecc7dd8b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [0.1.0] - 2026-06-04
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Initial release of `cdc-concurrent`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Async-backed I/O-concurrent runtime adapter for `cdc-core`.
|
|
8
|
+
- `CDC::Concurrent::Runtime` for processing single events, batches, and transaction envelopes.
|
|
9
|
+
- `CDC::Concurrent::ProcessorPool` for concurrent `ChangeEvent` processing.
|
|
10
|
+
- `CDC::Concurrent::TransactionPool` for transaction envelope processing.
|
|
11
|
+
- `CDC::Concurrent::Router` for routing supported CDC work items.
|
|
12
|
+
- `concurrent_safe!` processor declaration.
|
|
13
|
+
- Timeout handling with `CDC::Concurrent::TimeoutError`.
|
|
14
|
+
- Shutdown and unsupported work item errors.
|
|
15
|
+
- Result normalization to `CDC::Core::ProcessorResult`.
|
|
16
|
+
- Unit, integration, behavior, and performance test groups.
|
|
17
|
+
- RBS signatures.
|
|
18
|
+
- README positioning `cdc-concurrent` as the I/O-bound sibling of `cdc-parallel`.
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
|
|
22
|
+
- Requires Ruby 3.4+.
|
|
23
|
+
- Designed for I/O-bound processors that cooperate with Ruby's Fiber scheduler.
|
|
24
|
+
- CPU-bound CDC processing should use `cdc-parallel`.
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
module CDC
|
|
4
4
|
module Concurrent
|
|
5
5
|
# Immutable configuration for concurrent runtimes.
|
|
6
|
-
Configuration
|
|
6
|
+
class Configuration
|
|
7
|
+
attr_reader :concurrency, :timeout, :preserve_order
|
|
8
|
+
|
|
7
9
|
# @param concurrency [Integer] maximum concurrent tasks.
|
|
8
10
|
# @param timeout [Float, nil] optional timeout.
|
|
9
11
|
# @param preserve_order [Boolean] whether batch results preserve input order.
|
|
@@ -11,7 +13,9 @@ module CDC
|
|
|
11
13
|
raise ArgumentError, "concurrency must be an Integer" unless concurrency.is_a?(Integer)
|
|
12
14
|
raise ArgumentError, "concurrency must be greater than zero" unless concurrency.positive?
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
@concurrency = concurrency
|
|
17
|
+
@timeout = timeout
|
|
18
|
+
@preserve_order = preserve_order
|
|
15
19
|
freeze
|
|
16
20
|
end
|
|
17
21
|
end
|
|
@@ -20,7 +20,7 @@ module CDC
|
|
|
20
20
|
|
|
21
21
|
# @return [Boolean] whether this processor instance is concurrent-safe.
|
|
22
22
|
def concurrent_safe?
|
|
23
|
-
self.class.
|
|
23
|
+
self.class.instance_variable_get(:@concurrent_safe) == true
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -28,8 +28,9 @@ module CDC
|
|
|
28
28
|
# @return [Array<CDC::Core::ProcessorResult>]
|
|
29
29
|
def process_many(events)
|
|
30
30
|
raise ShutdownError, "processor pool has been shut down" if @shutdown
|
|
31
|
-
return
|
|
31
|
+
return empty_results if events.empty?
|
|
32
32
|
|
|
33
|
+
# @type var indexed_results: Array[[Integer, CDC::Core::ProcessorResult]]
|
|
33
34
|
indexed_results = []
|
|
34
35
|
|
|
35
36
|
process_batch(events, indexed_results)
|
|
@@ -51,6 +52,12 @@ module CDC
|
|
|
51
52
|
raise UnsafeProcessorError, "#{processor.class} must declare concurrent_safe!"
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
def empty_results
|
|
56
|
+
# @type var results: Array[CDC::Core::ProcessorResult]
|
|
57
|
+
results = []
|
|
58
|
+
results.freeze
|
|
59
|
+
end
|
|
60
|
+
|
|
54
61
|
def process_batch(events, indexed_results)
|
|
55
62
|
Async do |task|
|
|
56
63
|
semaphore = Async::Semaphore.new(@configuration.concurrency, parent: task)
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
module CDC
|
|
2
2
|
module Concurrent
|
|
3
3
|
# Immutable configuration for concurrent runtimes.
|
|
4
|
-
Configuration
|
|
4
|
+
class Configuration
|
|
5
|
+
attr_reader concurrency: Integer
|
|
6
|
+
attr_reader timeout: Float?
|
|
7
|
+
attr_reader preserve_order: bool
|
|
8
|
+
|
|
9
|
+
def initialize: (?concurrency: Integer, ?timeout: Float?, ?preserve_order: bool) -> void
|
|
10
|
+
end
|
|
5
11
|
end
|
|
6
12
|
end
|
data/sig/shims/async.rbs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Kernel
|
|
2
|
+
private
|
|
3
|
+
|
|
4
|
+
def Async: () { (Async::Task) -> untyped } -> Async::Task
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module Async
|
|
8
|
+
class Task
|
|
9
|
+
def with_timeout: (untyped timeout) { () -> untyped } -> untyped
|
|
10
|
+
def wait: () -> untyped
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Semaphore
|
|
14
|
+
def initialize: (Integer limit, parent: Task) -> void
|
|
15
|
+
def async: () { (Task) -> untyped } -> Task
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class TimeoutError < StandardError
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module CDC
|
|
2
|
+
module Core
|
|
3
|
+
class Processor
|
|
4
|
+
def self.extend: (Module mod) -> self
|
|
5
|
+
def self.include: (Module mod) -> self
|
|
6
|
+
|
|
7
|
+
def process: (untyped event) -> untyped
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class ProcessorResult
|
|
11
|
+
attr_reader status: Symbol
|
|
12
|
+
attr_reader event: untyped
|
|
13
|
+
attr_reader error: untyped
|
|
14
|
+
attr_reader metadata: untyped
|
|
15
|
+
|
|
16
|
+
def self.success: (?untyped event, ?metadata: untyped) -> ProcessorResult
|
|
17
|
+
def self.failure: (untyped error, ?event: untyped, ?metadata: untyped) -> ProcessorResult
|
|
18
|
+
|
|
19
|
+
def success?: () -> bool
|
|
20
|
+
def failure?: () -> bool
|
|
21
|
+
def skipped?: () -> bool
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class ChangeEvent
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class TransactionEnvelope
|
|
28
|
+
attr_reader events: Array[ChangeEvent]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cdc-concurrent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken C. Demanawa
|
|
@@ -72,6 +72,8 @@ files:
|
|
|
72
72
|
- sig/cdc/concurrent/transaction_pool.rbs
|
|
73
73
|
- sig/cdc/concurrent/version.rbs
|
|
74
74
|
- sig/cdc_concurrent.rbs
|
|
75
|
+
- sig/shims/async.rbs
|
|
76
|
+
- sig/shims/cdc_core.rbs
|
|
75
77
|
homepage: https://kanutocd.github.io/cdc-concurrent
|
|
76
78
|
licenses:
|
|
77
79
|
- MIT
|