cdc-core 0.1.0 → 0.1.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 +15 -7
- data/README.md +105 -19
- data/lib/cdc/core/composite_processor.rb +39 -14
- data/lib/cdc/core/errors.rb +9 -0
- data/lib/cdc/core/event_metadata.rb +4 -1
- data/lib/cdc/core/event_position.rb +48 -0
- data/lib/cdc/core/null_observer.rb +12 -0
- data/lib/cdc/core/observer.rb +123 -0
- data/lib/cdc/core/operation.rb +2 -0
- data/lib/cdc/core/ordering_key.rb +40 -0
- data/lib/cdc/core/ordering_policy.rb +106 -0
- data/lib/cdc/core/ordering_scope.rb +51 -0
- data/lib/cdc/core/pipeline.rb +23 -4
- data/lib/cdc/core/processor.rb +39 -0
- data/lib/cdc/core/processor_result.rb +96 -2
- data/lib/cdc/core/router.rb +91 -0
- data/lib/cdc/core/source_adapter.rb +41 -0
- data/lib/cdc/core/version.rb +1 -1
- data/lib/cdc/core.rb +12 -3
- data/sig/cdc/core/composite_processor.rbs +12 -1
- data/sig/cdc/core/errors.rbs +12 -0
- data/sig/cdc/core/event_position.rbs +21 -0
- data/sig/cdc/core/null_observer.rbs +8 -0
- data/sig/cdc/core/observer.rbs +25 -0
- data/sig/cdc/core/ordering_key.rbs +16 -0
- data/sig/cdc/core/ordering_policy.rbs +27 -0
- data/sig/cdc/core/ordering_scope.rbs +19 -0
- data/sig/cdc/core/pipeline.rbs +10 -1
- data/sig/cdc/core/processor.rbs +31 -0
- data/sig/cdc/core/processor_result.rbs +50 -1
- data/sig/cdc/core/router.rbs +24 -0
- data/sig/cdc/core/source_adapter.rbs +10 -0
- metadata +17 -1
data/sig/cdc/core/processor.rbs
CHANGED
|
@@ -23,6 +23,37 @@ module CDC
|
|
|
23
23
|
# @return [Boolean]
|
|
24
24
|
def ractor_safe?: () -> untyped
|
|
25
25
|
|
|
26
|
+
# Start the processor.
|
|
27
|
+
#
|
|
28
|
+
# Runtime layers can call this before dispatch begins. The default
|
|
29
|
+
# implementation is a no-op.
|
|
30
|
+
#
|
|
31
|
+
# @return [self]
|
|
32
|
+
def start: () -> self
|
|
33
|
+
|
|
34
|
+
# Stop the processor.
|
|
35
|
+
#
|
|
36
|
+
# Runtime layers can call this during shutdown. The default implementation
|
|
37
|
+
# is a no-op.
|
|
38
|
+
#
|
|
39
|
+
# @return [self]
|
|
40
|
+
def stop: () -> self
|
|
41
|
+
|
|
42
|
+
# Flush any buffered work.
|
|
43
|
+
#
|
|
44
|
+
# Runtime layers can call this before shutdown or checkpoints. The
|
|
45
|
+
# default implementation is a no-op.
|
|
46
|
+
#
|
|
47
|
+
# @return [self]
|
|
48
|
+
def flush: () -> self
|
|
49
|
+
|
|
50
|
+
# Whether the processor is healthy and ready to accept work.
|
|
51
|
+
#
|
|
52
|
+
# The default implementation assumes the processor is healthy.
|
|
53
|
+
#
|
|
54
|
+
# @return [Boolean]
|
|
55
|
+
def healthy?: () -> bool
|
|
56
|
+
|
|
26
57
|
# Process one event.
|
|
27
58
|
#
|
|
28
59
|
# Subclasses must override this method.
|
|
@@ -6,6 +6,7 @@ module CDC
|
|
|
6
6
|
# successful processing, skipped events, and failures without relying on
|
|
7
7
|
# processor-specific return values.
|
|
8
8
|
class ProcessorResult
|
|
9
|
+
VALID_STATUSES: untyped
|
|
9
10
|
@status: untyped
|
|
10
11
|
|
|
11
12
|
@event: untyped
|
|
@@ -49,9 +50,13 @@ module CDC
|
|
|
49
50
|
#
|
|
50
51
|
# @param error [Exception] processor error
|
|
51
52
|
# @param event [ChangeEvent, nil] event being processed
|
|
53
|
+
# @param reason [String, nil] human-readable failure reason
|
|
54
|
+
# @param retryable [Boolean, nil] whether the failure can be retried
|
|
55
|
+
# @param processor [String, nil] processor name associated with the failure
|
|
56
|
+
# @param failed_at [String, nil] timestamp for when the failure occurred
|
|
52
57
|
# @param metadata [Hash, EventMetadata] result metadata
|
|
53
58
|
# @return [ProcessorResult]
|
|
54
|
-
def self.failure: (untyped error, ?event: untyped?, ?
|
|
59
|
+
def self.failure: (untyped error, ?event: untyped?, ?reason: untyped?, ?retryable: untyped?, ?processor: untyped?, ?failed_at: untyped?, ?metadata: untyped) -> untyped
|
|
55
60
|
|
|
56
61
|
# Build a skipped result.
|
|
57
62
|
#
|
|
@@ -76,6 +81,50 @@ module CDC
|
|
|
76
81
|
|
|
77
82
|
# @return [Boolean] true when status is :skipped
|
|
78
83
|
def skipped?: () -> untyped
|
|
84
|
+
|
|
85
|
+
# Human-readable failure reason, when present.
|
|
86
|
+
#
|
|
87
|
+
# @return [String, nil]
|
|
88
|
+
def failure_reason: () -> untyped
|
|
89
|
+
|
|
90
|
+
# Whether the failure is retryable.
|
|
91
|
+
#
|
|
92
|
+
# @return [Boolean]
|
|
93
|
+
def retryable?: () -> bool
|
|
94
|
+
|
|
95
|
+
# Name of the processor associated with the failure, when present.
|
|
96
|
+
#
|
|
97
|
+
# @return [String, nil]
|
|
98
|
+
def processor_name: () -> untyped
|
|
99
|
+
|
|
100
|
+
# Timestamp for when the failure occurred, when present.
|
|
101
|
+
#
|
|
102
|
+
# @return [String, nil]
|
|
103
|
+
def failed_at: () -> untyped
|
|
104
|
+
|
|
105
|
+
# Error class name, when present.
|
|
106
|
+
#
|
|
107
|
+
# @return [String, nil]
|
|
108
|
+
def error_class: () -> untyped
|
|
109
|
+
|
|
110
|
+
# Error message, when present.
|
|
111
|
+
#
|
|
112
|
+
# @return [String, nil]
|
|
113
|
+
def error_message: () -> untyped
|
|
114
|
+
|
|
115
|
+
# Error backtrace, when present.
|
|
116
|
+
#
|
|
117
|
+
# @return [Array<String>]
|
|
118
|
+
def error_backtrace: () -> untyped
|
|
119
|
+
|
|
120
|
+
# Convert the result into a shareable hash.
|
|
121
|
+
#
|
|
122
|
+
# @return [Hash{String=>Object,nil}]
|
|
123
|
+
def to_h: () -> untyped
|
|
124
|
+
|
|
125
|
+
private
|
|
126
|
+
|
|
127
|
+
def normalize_status: (untyped status) -> untyped
|
|
79
128
|
end
|
|
80
129
|
end
|
|
81
130
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module CDC
|
|
2
|
+
module Core
|
|
3
|
+
# Routes CDC work items to the appropriate handler.
|
|
4
|
+
class Router
|
|
5
|
+
@processor: untyped
|
|
6
|
+
@transaction_processor: untyped
|
|
7
|
+
@observer: untyped
|
|
8
|
+
|
|
9
|
+
attr_reader processor: untyped
|
|
10
|
+
attr_reader transaction_processor: untyped
|
|
11
|
+
attr_reader observer: untyped
|
|
12
|
+
|
|
13
|
+
def initialize: (processor: untyped, ?transaction_processor: untyped?, ?observer: untyped?) -> void
|
|
14
|
+
def process: (untyped item) -> untyped
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def route_transaction: (untyped transaction) -> untyped
|
|
19
|
+
def route_many: (untyped items) -> untyped
|
|
20
|
+
def observe_result: (untyped result) -> untyped
|
|
21
|
+
def observe_results: (untyped results) -> untyped
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Base class for source adapters that normalize upstream payloads into CDC
|
|
2
|
+
# core domain objects.
|
|
3
|
+
module CDC
|
|
4
|
+
module Core
|
|
5
|
+
class SourceAdapter
|
|
6
|
+
def normalize: (untyped input) -> untyped
|
|
7
|
+
def normalize_many: (untyped inputs) -> ::Array[untyped]
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cdc-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken C. Demanawa
|
|
@@ -28,11 +28,19 @@ files:
|
|
|
28
28
|
- lib/cdc/core/composite_processor.rb
|
|
29
29
|
- lib/cdc/core/errors.rb
|
|
30
30
|
- lib/cdc/core/event_metadata.rb
|
|
31
|
+
- lib/cdc/core/event_position.rb
|
|
31
32
|
- lib/cdc/core/filter.rb
|
|
33
|
+
- lib/cdc/core/null_observer.rb
|
|
34
|
+
- lib/cdc/core/observer.rb
|
|
32
35
|
- lib/cdc/core/operation.rb
|
|
36
|
+
- lib/cdc/core/ordering_key.rb
|
|
37
|
+
- lib/cdc/core/ordering_policy.rb
|
|
38
|
+
- lib/cdc/core/ordering_scope.rb
|
|
33
39
|
- lib/cdc/core/pipeline.rb
|
|
34
40
|
- lib/cdc/core/processor.rb
|
|
35
41
|
- lib/cdc/core/processor_result.rb
|
|
42
|
+
- lib/cdc/core/router.rb
|
|
43
|
+
- lib/cdc/core/source_adapter.rb
|
|
36
44
|
- lib/cdc/core/transaction_envelope.rb
|
|
37
45
|
- lib/cdc/core/version.rb
|
|
38
46
|
- lib/cdc_core.rb
|
|
@@ -42,11 +50,19 @@ files:
|
|
|
42
50
|
- sig/cdc/core/composite_processor.rbs
|
|
43
51
|
- sig/cdc/core/errors.rbs
|
|
44
52
|
- sig/cdc/core/event_metadata.rbs
|
|
53
|
+
- sig/cdc/core/event_position.rbs
|
|
45
54
|
- sig/cdc/core/filter.rbs
|
|
55
|
+
- sig/cdc/core/null_observer.rbs
|
|
56
|
+
- sig/cdc/core/observer.rbs
|
|
46
57
|
- sig/cdc/core/operation.rbs
|
|
58
|
+
- sig/cdc/core/ordering_key.rbs
|
|
59
|
+
- sig/cdc/core/ordering_policy.rbs
|
|
60
|
+
- sig/cdc/core/ordering_scope.rbs
|
|
47
61
|
- sig/cdc/core/pipeline.rbs
|
|
48
62
|
- sig/cdc/core/processor.rbs
|
|
49
63
|
- sig/cdc/core/processor_result.rbs
|
|
64
|
+
- sig/cdc/core/router.rbs
|
|
65
|
+
- sig/cdc/core/source_adapter.rbs
|
|
50
66
|
- sig/cdc/core/transaction_envelope.rbs
|
|
51
67
|
- sig/cdc/core/version.rbs
|
|
52
68
|
- sig/cdc_core.rbs
|