Skip to content

Commit 3d35f68

Browse files
committed
up
1 parent 3ae698b commit 3d35f68

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lib/event_processor/event_store.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { EventWithId } from "./batch_event_processor";
2+
import { AsyncPrefixStore, OpStore, Store, SyncPrefixStore } from "../utils/cache/store";
3+
import { Maybe, OpType, OpValue } from "../utils/type";
4+
5+
type StoredEvent = EventWithId & {
6+
storedAt?: number;
7+
};
8+
9+
export class EventStore<OP extends OpType> implements OpStore<OP, EventWithId> {
10+
private store: OpStore<OP, StoredEvent>;
11+
readonly operation: OP;
12+
private keysSet?: Set<string>;
13+
14+
constructor(store: OpStore<OP, EventWithId>) {
15+
if (store.operation === 'sync') {
16+
this.store = new SyncPrefixStore(store as OpStore<'sync', EventWithId>, 'optly_event:', a => a, a => a) as unknown as OpStore<OP, StoredEvent>;
17+
} else {
18+
this.store = new AsyncPrefixStore(store as OpStore<'async', EventWithId>, 'optly_event:', a => a, a => a) as unknown as OpStore<OP, StoredEvent>;
19+
}
20+
21+
this.operation = store.operation;
22+
}
23+
24+
set(key: string, value: EventWithId): OpValue<OP, unknown> {
25+
throw new Error("Method not implemented.");
26+
}
27+
28+
get(key: string): OpValue<OP, Maybe<EventWithId>> {
29+
throw new Error("Method not implemented.");
30+
}
31+
32+
remove(key: string): OpValue<OP, unknown> {
33+
throw new Error("Method not implemented.");
34+
}
35+
36+
getKeys(): OpValue<OP, string[]> {
37+
throw new Error("Method not implemented.");
38+
}
39+
}

0 commit comments

Comments
 (0)