@anabranch/eventlog 0.1.2 → 0.2.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.
package/README.md CHANGED
@@ -1,28 +1,36 @@
1
1
  # @anabranch/eventlog
2
2
 
3
- Event log with **Task/Stream** semantics for event-sourced systems. Built for
4
- reliable, cursor-based consumption and functional error handling.
3
+ Event log with Task/Stream semantics for event-sourced systems with cursor-based
4
+ consumption.
5
5
 
6
- ## Description
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.
7
9
 
8
- A high-level event log abstraction that integrates with `@anabranch/task`. By
9
- representing log operations as **Tasks**, you get first-class support for
10
- retries, timeouts, and `AbortSignal` propagation out of the box.
10
+ ## Usage
11
11
 
12
- This library provides a unified interface for appending and consuming events
13
- across different storage backends while maintaining strict type safety and lazy
14
- execution patterns.
12
+ ```ts
13
+ import { createInMemory, EventLog } from '@anabranch/eventlog'
15
14
 
16
- ## Features
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()
17
20
 
18
- - **Lazy Execution**: Operations return a `Task`. Nothing happens until you
19
- `.run()`.
20
- - **First-Class Cancellation**: Built-in `AbortSignal` merging across all
21
- operations.
22
- - **Cursor-Based**: Resume processing from any position with consumer groups.
23
- - **At-Least-Once Delivery**: Manual acknowledgement gives you full control.
24
- - **Pluggable Architecture**: Standardized adapter interface for any storage
25
- backend.
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()
33
+ ```
26
34
 
27
35
  ## Installation
28
36
 
@@ -34,97 +42,23 @@ jsr add @anabranch/eventlog
34
42
  deno add @anabranch/eventlog
35
43
  ```
36
44
 
37
- ## Quick Start
38
-
39
- ```ts
40
- import { createInMemory, EventLog } from "@anabranch/eventlog";
41
-
42
- const connector = createInMemory();
43
-
44
- // Compose your logic as a Task chain
45
- const program = EventLog.connect(connector).flatMap((log) => {
46
- return log
47
- .append("users", { type: "signup", email: "alice@example.com" })
48
- .tap(() => console.log("Event appended!"))
49
- .flatMap(() => log.get("users", 0));
50
- });
51
-
52
- // Execute the task at the edge of your application
53
- const result = await program.result();
54
-
55
- if (result.type === "success") {
56
- console.log("User at sequence 0:", result.value);
57
- }
58
- ```
59
-
60
- ## Reliable Consumption
61
-
62
- The `.consume()` method returns a Stream of batches. To guarantee at-least-once
63
- delivery, you manually commit the cursor after successful processing.
64
-
65
- ```ts
66
- const log = await EventLog.connect(connector).run();
67
-
68
- const consumer = log
69
- .consume("users", "email-service", { batchSize: 10 })
70
- .map(async (batch) => {
71
- // 1. Process your events
72
- for (const event of batch.events) {
73
- await sendWelcomeEmail(event.data);
74
- }
75
- // 2. Commit the cursor only after success
76
- await log.commit(batch.topic, batch.consumerGroup, batch.cursor).run();
77
- });
78
-
79
- // Run the consumer
80
- await consumer.run();
81
- ```
82
-
83
- ## API
84
-
85
- ### `EventLog.connect(adapter)`
86
-
87
- Initializes the connection. Returns a
88
- `Task<EventLog, EventLogConnectionFailed>`.
89
-
90
- ### `log.append(topic, data, options?)`
91
-
92
- Appends an event. Options include `partitionKey` and `metadata`.\
93
- Returns `Task<string, EventLogAppendFailed>`.
94
-
95
- ### `log.consume(topic, consumerGroup, options?)`
96
-
97
- Returns a Stream of event batches. If a cursor is found for the group, it
98
- resumes automatically.
99
-
100
- ### `log.commit(topic, consumerGroup, cursor)`
101
-
102
- Persists the progress for a specific consumer group.
103
-
104
- ---
45
+ ## Features
105
46
 
106
- ## Error Handling
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
107
54
 
108
- Because operations are Tasks, you can handle failures declaratively:
55
+ ## API Reference
109
56
 
110
- ```ts
111
- const task = log.append("orders", data)
112
- .retry({
113
- attempts: 3,
114
- delay: (n) => Math.pow(2, n) * 1000, // Exponential backoff
115
- when: (err) => err instanceof EventLogAppendFailed,
116
- })
117
- .timeout(5000)
118
- .recover((err) => {
119
- console.error("Critical failure:", err);
120
- return "FALLBACK_ID";
121
- });
122
-
123
- const eventId = await task.run();
124
- ```
57
+ See
58
+ [generated documentation](https://frodi-karlsson.github.io/anabranch/eventlog)
59
+ for full API details.
125
60
 
126
61
  ## Related
127
62
 
128
- - [@anabranch/task](https://jsr.io/@anabranch/task) - Core Task primitives
129
- - [@anabranch/stream](https://jsr.io/@anabranch/stream) - Reactive stream
130
- processing
63
+ - [@anabranch/anabranch](https://jsr.io/@anabranch/anabranch) - Core Task/Stream
64
+ primitives
package/esm/adapter.d.ts CHANGED
@@ -1,96 +1,117 @@
1
+ import { Promisable } from 'anabranch';
2
+ import { EventLogConsumeFailed } from './errors.js';
1
3
  /**
2
- * Event log adapter interface for event-sourced systems.
3
- *
4
- * Implement this interface to create drivers for specific event stores.
5
- * The EventLog class wraps adapters with Task/Stream semantics.
6
- *
7
- * For connection lifecycle management, use EventLogConnector which produces adapters.
8
- * The adapter's close() method releases the connection rather than terminating it.
4
+ * A single event in the event log.
9
5
  */
10
- /** A single event in the log. */
11
6
  export interface Event<T = unknown> {
12
- /** Unique event identifier (globally unique) */
7
+ /** Unique identifier for this event. */
13
8
  id: string;
14
- /** Topic/stream this event belongs to */
9
+ /** The topic this event belongs to. */
15
10
  topic: string;
16
- /** Event payload */
11
+ /** The event data payload. */
17
12
  data: T;
18
- /** Partition key for ordering guarantees */
13
+ /** Partition key for ordering guarantees. */
19
14
  partitionKey: string;
20
- /** Event sequence number within the topic */
21
- sequenceNumber: number;
22
- /** Timestamp when the event was created */
15
+ /** Monotonically increasing sequence number within the topic. Represented as a string to support bigint while remaining serializable. */
16
+ sequenceNumber: string;
17
+ /** Unix timestamp in milliseconds when the event was created. */
23
18
  timestamp: number;
24
- /** Optional metadata attached to the event */
19
+ /** Optional metadata associated with the event. */
25
20
  metadata?: Record<string, unknown>;
26
21
  }
27
- /** A batch of events consumed from a topic. */
28
- export interface EventBatch<T = unknown> {
29
- /** Topic these events belong to */
22
+ /**
23
+ * A batch of events delivered to a consumer.
24
+ */
25
+ export interface EventBatch<T = unknown, Cursor = string> {
26
+ /** The topic this batch was received from. */
30
27
  topic: string;
31
- /** Consumer group that consumed these events */
28
+ /** The consumer group that received this batch. */
32
29
  consumerGroup: string;
33
- /** Events in this batch */
30
+ /** Events in this batch. */
34
31
  events: Event<T>[];
35
- /** Cursor position for this batch (opaque to caller) */
36
- cursor: string;
32
+ /** Cursor representing the position after this batch. Use for manual commits. */
33
+ cursor: Cursor;
34
+ /**
35
+ * Commit this batch's cursor to mark progress.
36
+ *
37
+ * After processing events successfully, call this to save the cursor position.
38
+ * On restart, the consumer will resume from this position.
39
+ */
40
+ commit(): Promise<void>;
37
41
  }
38
42
  /**
39
- * Event log adapter interface for low-level operations.
43
+ * Low-level adapter interface for event log implementations.
44
+ *
45
+ * Adapters handle the actual communication with the underlying event store
46
+ * (in-memory, Kafka, etc.). Use connectors to create adapter instances.
40
47
  */
41
- export interface EventLogAdapter {
42
- /** Append an event to a topic. Returns the event ID. */
48
+ export interface EventLogAdapter<Cursor = string> {
49
+ /**
50
+ * Append an event to a topic.
51
+ */
43
52
  append<T>(topic: string, data: T, options?: AppendOptions): Promise<string>;
44
- /** Get a single event by ID. */
45
- get<T>(topic: string, sequenceNumber: number): Promise<Event<T> | null>;
46
- /** List events in a topic with optional filtering. */
47
- list<T>(topic: string, options?: ListOptions): Promise<Event<T>[]>;
48
- /** Consume events from a topic as a streaming async iterable. */
49
- consume<T>(topic: string, consumerGroup: string, options?: ConsumeOptions): AsyncIterable<EventBatch<T>>;
50
- /** Commit a cursor position for a consumer group. */
51
- commitCursor(topic: string, consumerGroup: string, cursor: string): Promise<void>;
52
- /** Get the committed cursor position for a consumer group. */
53
- getCursor(topic: string, consumerGroup: string): Promise<string | null>;
54
- /** Close the adapter connection. */
53
+ /**
54
+ * Consume events from a topic.
55
+ */
56
+ consume<T>(topic: string, consumerGroup: string, onBatch: (batch: EventBatch<T, Cursor>) => Promisable<void>, onError: (error: EventLogConsumeFailed) => Promisable<void>, options?: ConsumeOptions<Cursor>): {
57
+ close: () => Promise<void>;
58
+ };
59
+ /**
60
+ * Get the last committed cursor for a consumer group.
61
+ */
62
+ getCursor(topic: string, consumerGroup: string): Promise<Cursor | null>;
63
+ /**
64
+ * Commit a cursor for a consumer group.
65
+ */
66
+ commitCursor(topic: string, consumerGroup: string, cursor: Cursor): Promise<void>;
67
+ /** Close the adapter and release resources. */
55
68
  close(): Promise<void>;
56
69
  }
57
- /** Options for appending an event. */
70
+ /** Options for appending events. */
58
71
  export interface AppendOptions {
59
- /** Partition key for ordering guarantees within the topic */
72
+ /** Key for partitioning and ordering. Events with the same key are ordered. */
60
73
  partitionKey?: string;
61
- /** Optional metadata attached to the event */
74
+ /** Custom metadata to attach to the event. */
62
75
  metadata?: Record<string, unknown>;
63
- /** Timestamp for the event (defaults to now) */
76
+ /** Custom timestamp in milliseconds. Defaults to Date.now(). */
64
77
  timestamp?: number;
65
78
  }
66
- /** Options for listing events. */
67
- export interface ListOptions {
68
- /** Starting sequence number (inclusive) */
69
- fromSequenceNumber?: number;
70
- /** Maximum number of events to return */
71
- limit?: number;
72
- /** Filter by partition key */
73
- partitionKey?: string;
74
- }
75
79
  /** Options for consuming events. */
76
- export interface ConsumeOptions {
77
- /** Signal for cancellation */
80
+ export interface ConsumeOptions<Cursor = string> {
81
+ /** Abort signal to cancel consumption. */
78
82
  signal?: AbortSignal;
79
- /** Starting cursor (null means from beginning) */
80
- cursor?: string | null;
81
- /** Batch size for events */
83
+ /** Cursor to resume from. If null, starts from the beginning. */
84
+ cursor?: Cursor | null;
85
+ /** Maximum number of events per batch. Defaults to adapter-specific value. */
82
86
  batchSize?: number;
87
+ /** Maximum number of batches to buffer. Defaults to adapter-specific value.
88
+ * When the buffer is full, new batches will be dropped and onError will be called with an EventLogConsumeFailed error.
89
+ * @default Infinity
90
+ */
91
+ bufferSize?: number;
83
92
  }
84
- /** Connector that produces connected EventLogAdapter instances. */
85
- export interface EventLogConnector {
86
- /** Acquire a connected adapter. */
87
- connect(signal?: AbortSignal): Promise<EventLogAdapter>;
88
- /** Close all connections and clean up resources. */
93
+ /**
94
+ * Factory for creating event log connections.
95
+ *
96
+ * Connectors manage connection lifecycle and produce adapter instances.
97
+ * Use connectors in production code to properly manage resources.
98
+ */
99
+ export interface EventLogConnector<Cursor = string> {
100
+ /**
101
+ * Connect to the event log.
102
+ */
103
+ connect(signal?: AbortSignal): Promise<EventLogAdapter<Cursor>>;
104
+ /**
105
+ * End the connector and release all resources.
106
+ *
107
+ * After calling end(), all adapters created by this connector become
108
+ * invalid and subsequent connect() calls will fail.
109
+ */
89
110
  end(): Promise<void>;
90
111
  }
91
- /** Event log configuration options. */
112
+ /** Configuration options for event log implementations. */
92
113
  export interface EventLogOptions {
93
- /** Default partition key if not specified */
114
+ /** Default partition key for events without explicit keys. */
94
115
  defaultPartitionKey?: string;
95
116
  }
96
117
  //# sourceMappingURL=adapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iCAAiC;AACjC,MAAM,WAAW,KAAK,CAAC,CAAC,GAAG,OAAO;IAChC,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB;IACpB,IAAI,EAAE,CAAC,CAA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C,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;IAE/D;;;;;OAKG;IACH,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACrB;AAED,2DAA2D;AAC3D,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B"}
package/esm/adapter.js CHANGED
@@ -1,10 +1 @@
1
- /**
2
- * Event log adapter interface for event-sourced systems.
3
- *
4
- * Implement this interface to create drivers for specific event stores.
5
- * The EventLog class wraps adapters with Task/Stream semantics.
6
- *
7
- * For connection lifecycle management, use EventLogConnector which produces adapters.
8
- * The adapter's close() method releases the connection rather than terminating it.
9
- */
10
1
  export {};
package/esm/errors.d.ts CHANGED
@@ -10,13 +10,8 @@ export declare class EventLogAppendFailed extends Error {
10
10
  name: string;
11
11
  constructor(topic: string, message: string, cause?: unknown);
12
12
  }
13
- /** Error thrown when getting an event fails. */
14
- export declare class EventLogGetFailed extends Error {
15
- name: string;
16
- constructor(topic: string, sequenceNumber: number, message: string, cause?: unknown);
17
- }
18
- /** Error thrown when listing events fails. */
19
- export declare class EventLogListFailed extends Error {
13
+ /** Error thrown when consuming events fails. */
14
+ export declare class EventLogConsumeFailed extends Error {
20
15
  name: string;
21
16
  constructor(topic: string, message: string, cause?: unknown);
22
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;IACxC,IAAI,SAA8B;gBAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG7C;AAED,mDAAmD;AACnD,qBAAa,oBAAqB,SAAQ,KAAK;IACpC,IAAI,SAA0B;gBAC3B,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG5D;AAED,gDAAgD;AAChD,qBAAa,iBAAkB,SAAQ,K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O,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG5D;AAED,mDAAmD;AACnD,qBAAa,0BAA2B,SAAQ,KAAK;IAC1C,IAAI,SAA+B;gBAE1C,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO;CAOlB;AAED,gDAAgD;AAChD,qBAAa,uBAAwB,SAAQ,KAAK;IACvC,IAAI,SAA4B;gBAEvC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,OAAO;CAOlB;AAED,+DAA+D;AAC/D,qBAAa,mBAAoB,SAAQ,KAAK;IACnC,IAAI,SAAwB;gBACzB,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAG7C"}
package/esm/errors.js CHANGED
@@ -8,7 +8,7 @@ export class EventLogConnectionFailed extends Error {
8
8
  enumerable: true,
9
9
  configurable: true,
10
10
  writable: true,
11
- value: "EventLogConnectionFailed"
11
+ value: 'EventLogConnectionFailed'
12
12
  });
13
13
  }
14
14
  }
@@ -20,31 +20,19 @@ export class EventLogAppendFailed extends Error {
20
20
  enumerable: true,
21
21
  configurable: true,
22
22
  writable: true,
23
- value: "EventLogAppendFailed"
23
+ value: 'EventLogAppendFailed'
24
24
  });
25
25
  }
26
26
  }
27
- /** Error thrown when getting an event fails. */
28
- export class EventLogGetFailed extends Error {
29
- constructor(topic, sequenceNumber, message, cause) {
30
- super(`Failed to get event ${sequenceNumber} from ${topic}: ${message}`, { cause });
31
- Object.defineProperty(this, "name", {
32
- enumerable: true,
33
- configurable: true,
34
- writable: true,
35
- value: "EventLogGetFailed"
36
- });
37
- }
38
- }
39
- /** Error thrown when listing events fails. */
40
- export class EventLogListFailed extends Error {
27
+ /** Error thrown when consuming events fails. */
28
+ export class EventLogConsumeFailed extends Error {
41
29
  constructor(topic, message, cause) {
42
- super(`Failed to list events from ${topic}: ${message}`, { cause });
30
+ super(`Failed to consume events from ${topic}: ${message}`, { cause });
43
31
  Object.defineProperty(this, "name", {
44
32
  enumerable: true,
45
33
  configurable: true,
46
34
  writable: true,
47
- value: "EventLogListFailed"
35
+ value: 'EventLogConsumeFailed'
48
36
  });
49
37
  }
50
38
  }
@@ -56,7 +44,7 @@ export class EventLogCommitCursorFailed extends Error {
56
44
  enumerable: true,
57
45
  configurable: true,
58
46
  writable: true,
59
- value: "EventLogCommitCursorFailed"
47
+ value: 'EventLogCommitCursorFailed'
60
48
  });
61
49
  }
62
50
  }
@@ -68,7 +56,7 @@ export class EventLogGetCursorFailed extends Error {
68
56
  enumerable: true,
69
57
  configurable: true,
70
58
  writable: true,
71
- value: "EventLogGetCursorFailed"
59
+ value: 'EventLogGetCursorFailed'
72
60
  });
73
61
  }
74
62
  }
@@ -80,7 +68,7 @@ export class EventLogCloseFailed extends Error {
80
68
  enumerable: true,
81
69
  configurable: true,
82
70
  writable: true,
83
- value: "EventLogCloseFailed"
71
+ value: 'EventLogCloseFailed'
84
72
  });
85
73
  }
86
74
  }