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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8f1b6796df6daf32144dc7df7206777863c4d693997e3b83e500d0c360ff699
4
- data.tar.gz: eabe19f74600193950154f4921203123b78bd1c2db8a2ca576bf74c83ab1eb5b
3
+ metadata.gz: cbc0a0ebe15a9254e91b40caa48db7f7f26e4b01933be88e5fd148ea8c3371d0
4
+ data.tar.gz: 38888cc8ade72e4611e352fa534a25876cbc71d6ef74c2f725b5bb3ef1c4c069
5
5
  SHA512:
6
- metadata.gz: eabccfa38225330187c12f4c681c68f973126e60910c00402cc274a400e776753e46b1a5605692b363f8d064971cb26253ab72d305b69d9e2106e49733c964d7
7
- data.tar.gz: 2210868f800f9ae0cddf5cf24bf6104be5dfd9f74d2b74694f66571cdd87031ba714ba2b12356c4401b71e4dcad901187848ad1f8a8746f7e0b2f236122dec9c
6
+ metadata.gz: c3315531e5f0cbe43f86461acabf835ec5f187d65dace206d1640a213b42702a0ee8e1088421f1e2f05e076ce9dfcdd7625f309f837b613c5f13dfc459b07152
7
+ data.tar.gz: 351566c71b92c033c2c35b2639653eabf6e75d3bacee667f643dde9af47bffaf7dbeee4f802eb8e237bd5e9a5bc7957d43269b323fc9c17b89bedda1ecc7dd8b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
- ## [Unreleased]
1
+ ## [0.1.0] - 2026-06-04
2
2
 
3
- ## [0.1.0] - 2026-05-31
3
+ Initial release of `cdc-concurrent`.
4
4
 
5
- - Initial release
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 = Data.define(:concurrency, :timeout, :preserve_order) do
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
- super
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.respond_to?(:concurrent_safe?) && self.class.concurrent_safe?
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 [].freeze if events.empty?
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)
@@ -3,6 +3,6 @@
3
3
  module CDC
4
4
  module Concurrent
5
5
  # Current cdc-concurrent version.
6
- VERSION = "0.0.0"
6
+ VERSION = "0.1.0"
7
7
  end
8
8
  end
@@ -1,6 +1,12 @@
1
1
  module CDC
2
2
  module Concurrent
3
3
  # Immutable configuration for concurrent runtimes.
4
- Configuration: untyped
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
@@ -29,6 +29,8 @@ module CDC
29
29
 
30
30
  def validate_processor!: (untyped processor) -> (nil | untyped)
31
31
 
32
+ def empty_results: () -> ::Array[untyped]
33
+
32
34
  def process_batch: (untyped events, untyped indexed_results) -> untyped
33
35
 
34
36
  def process_one: (untyped event) -> untyped
@@ -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.0.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