@anabranch/eventlog 0.1.0 → 0.1.3
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 +53 -6
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,17 +1,64 @@
|
|
|
1
1
|
# @anabranch/eventlog
|
|
2
2
|
|
|
3
|
-
Event log with Task/Stream semantics
|
|
4
|
-
|
|
3
|
+
Event log with Task/Stream semantics for event-sourced systems with cursor-based
|
|
4
|
+
consumption.
|
|
5
|
+
|
|
6
|
+
A high-level event log abstraction that integrates with anabranch's Task and
|
|
7
|
+
Stream types for composable error handling, concurrent processing, and reliable
|
|
8
|
+
consumer resumption.
|
|
5
9
|
|
|
6
10
|
## Usage
|
|
7
11
|
|
|
8
12
|
```ts
|
|
9
|
-
import {} from "@anabranch/eventlog";
|
|
13
|
+
import { createInMemory, EventLog } from "@anabranch/eventlog";
|
|
14
|
+
|
|
15
|
+
const connector = createInMemory();
|
|
16
|
+
const log = await EventLog.connect(connector).run();
|
|
17
|
+
|
|
18
|
+
// Append an event
|
|
19
|
+
await log.append("users", { type: "created", userId: 123 }).run();
|
|
20
|
+
|
|
21
|
+
// Consume events with cursor-based resumption
|
|
22
|
+
const { successes, errors } = await log
|
|
23
|
+
.consume("users", "my-processor", { batchSize: 10 })
|
|
24
|
+
.withConcurrency(5)
|
|
25
|
+
.map(async (batch) => {
|
|
26
|
+
for (const event of batch.events) {
|
|
27
|
+
await handleEvent(event.data);
|
|
28
|
+
}
|
|
29
|
+
// Manual commit for at-least-once delivery
|
|
30
|
+
await log.commit(batch.topic, batch.consumerGroup, batch.cursor).run();
|
|
31
|
+
})
|
|
32
|
+
.partition();
|
|
10
33
|
```
|
|
11
34
|
|
|
12
|
-
##
|
|
35
|
+
## Installation
|
|
13
36
|
|
|
14
|
-
|
|
37
|
+
```bash
|
|
38
|
+
# JSR
|
|
39
|
+
jsr add @anabranch/eventlog
|
|
15
40
|
|
|
16
|
-
|
|
41
|
+
# Deno
|
|
42
|
+
deno add @anabranch/eventlog
|
|
17
43
|
```
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
- **Cursor-Based Consumption**: Resume processing from any position without data
|
|
48
|
+
loss
|
|
49
|
+
- **At-Least-Once Delivery**: Manual commit gives you control over processing
|
|
50
|
+
guarantees
|
|
51
|
+
- **Task/Stream Integration**: Leverage Task's retry/timeout and Stream's error
|
|
52
|
+
collection
|
|
53
|
+
- **Multiple Adapters**: In-memory implementation included
|
|
54
|
+
|
|
55
|
+
## API Reference
|
|
56
|
+
|
|
57
|
+
See
|
|
58
|
+
[generated documentation](https://frodi-karlsson.github.io/anabranch/eventlog)
|
|
59
|
+
for full API details.
|
|
60
|
+
|
|
61
|
+
## Related
|
|
62
|
+
|
|
63
|
+
- [@anabranch/anabranch](https://jsr.io/@anabranch/anabranch) - Core Task/Stream
|
|
64
|
+
primitives
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anabranch/eventlog",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Event log with Task/Stream semantics. In-memory adapter for event-sourced systems with cursor-based consumption.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,5 +20,8 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"anabranch": "^0"
|
|
22
22
|
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/node": "^24"
|
|
25
|
+
},
|
|
23
26
|
"_generatedBy": "dnt@dev"
|
|
24
27
|
}
|