@siglo/kafka 1.0.0 → 1.0.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.
- package/README.md +17 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
## 1. Overview & Architecture
|
|
8
8
|
|
|
9
|
-
In an event-driven architecture, Kafka delivers partitioned event streams to consumer groups. The `@siglo/kafka` adapter handles incoming messages
|
|
9
|
+
In an event-driven architecture, Kafka delivers partitioned event streams to consumer groups. The `@siglo/kafka` adapter handles incoming messages with at-least-once processing semantics, coordinates deduplication via an `IdempotencyStore`, and executes the workflow within configured timeout bounds.
|
|
10
|
+
|
|
11
|
+
> **Note on Guarantees**: Claims and cached results do not make external side-effects atomic with record completion. When a Kafka message is delivered, the whole workflow executes from the beginning; it does not automatically resume at the last successful step. A crash after an external effect (e.g. payment charge) succeeds but before claim completion leaves an in-progress claim until expiry, which may repeat the external effect upon message redelivery. Workflows must design external effects to be idempotent or supply provider-level deduplication keys.
|
|
10
12
|
|
|
11
13
|
```mermaid
|
|
12
14
|
flowchart TD
|
|
@@ -41,24 +43,21 @@ flowchart TD
|
|
|
41
43
|
S10 --> Commit["Commit Kafka Offset"]
|
|
42
44
|
```
|
|
43
45
|
|
|
44
|
-
###
|
|
46
|
+
### In-Process Execution Architectural Trade-offs
|
|
45
47
|
|
|
46
|
-
| Dimension | In-Process Orchestration (`Siglo`) | Distributed Step Orchestration
|
|
48
|
+
| Dimension | In-Process Orchestration (`Siglo`) | Distributed Step Orchestration |
|
|
47
49
|
| :--- | :--- | :--- |
|
|
48
|
-
| **Step-to-Step
|
|
49
|
-
| **
|
|
50
|
-
| **
|
|
51
|
-
| **
|
|
52
|
-
| **
|
|
53
|
-
| **
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
In such systems, **95% of total workflow duration is spent waiting for network hops and queue contention**, and only 5% executing real code. In `Siglo`, Step 1 immediately yields to Step 2 in memory with zero serialization penalty.
|
|
60
|
-
|
|
61
|
-
#### 2. How High-Throughput Scaling Actually Works
|
|
50
|
+
| **Step-to-Step Invocation** | Direct in-memory async promise chaining. | Every step requires network RPC, queue write, and external coordination. |
|
|
51
|
+
| **Execution Boundary** | Runs full workflow in-process on consumer node. | Dispatches individual steps across cluster workers. |
|
|
52
|
+
| **Payload Handling** | Pass rich domain models, Buffers, Maps, or Streams directly in memory. | Payloads must be serialized to JSON across each step boundary. |
|
|
53
|
+
| **Infrastructure Overhead** | Runs directly inside your application container with no extra engine servers. | Requires external orchestrator clusters and database infrastructure. |
|
|
54
|
+
| **Debugging & Local Testing** | Standard debugger breakpoints stepping directly between steps. | Requires cross-machine distributed trace correlation and event replay. |
|
|
55
|
+
| **Saga Compensation** | Immediate in-process reverse rollback if downstream step fails. | Rollback messages queue behind other cluster tasks. |
|
|
56
|
+
|
|
57
|
+
#### 1. In-Process vs. Multi-Hop Step Orchestration
|
|
58
|
+
In systems that distribute every individual step to different servers across a network, each step boundary incurs serialization, broker scheduling, and network transfer overhead. In `Siglo`, Step 1 yields to Step 2 directly in memory with zero network latency.
|
|
59
|
+
|
|
60
|
+
#### 2. Horizontally Scaling via Partitions
|
|
62
61
|
Work is scaled horizontally by **Kafka Partitions (Message-Level Distribution)**, not by splitting individual steps across machines:
|
|
63
62
|
|
|
64
63
|
```mermaid
|
|
@@ -202,7 +201,7 @@ export interface SigloKafkaMessage {
|
|
|
202
201
|
| `input` | `(message: SigloKafkaMessage) => Promise<TInput> \| TInput` | JSON parser on `message.value` | Custom transformer converting Kafka record into workflow input. |
|
|
203
202
|
| `output` | `(result: any, message: SigloKafkaMessage) => Promise<TOutput> \| TOutput` | `result` | Custom post-processor formatting the workflow output. |
|
|
204
203
|
| `idempotencyStore` | `IdempotencyStore` | `undefined` | Distributed store (e.g., `RedisIdempotencyStore` or `PostgresIdempotencyStore`) to prevent duplicate processing. |
|
|
205
|
-
| `idempotencyTtlMs` | `number` | `
|
|
204
|
+
| `idempotencyTtlMs` | `number` | `undefined` | Time-to-live for idempotency claim lock. Passed through to store (Redis/Postgres default: 24h; InMemory has no default expiration unless specified). |
|
|
206
205
|
| `timeout` | `number` | `undefined` | SLA execution timeout in milliseconds. |
|
|
207
206
|
| `namespace` | `string \| ((message: SigloKafkaMessage) => string \| undefined)` | `message.headers['x-namespace']` | Namespace identifier for tenant partitioning. |
|
|
208
207
|
|