Skip to content

Commit 29016b0

Browse files
committed
refactor: wip
1 parent e0c210e commit 29016b0

19 files changed

+1436
-1545
lines changed

packages/utils/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default tseslint.config(
1313
},
1414
},
1515
{
16-
files: ['packages/utils/src/lib/**/file-sink*.ts'],
16+
files: ['packages/utils/src/lib/**/wal*.ts'],
1717
rules: {
1818
'n/no-sync': 'off',
1919
},

packages/utils/mocks/sink.mock.ts

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,55 @@
1-
import type { Sink } from '../src/lib/sink-source.type';
1+
import { WriteAheadLogFile } from '../src/lib/profiler/wal.js';
2+
import type { Codec } from '../src/lib/types.js';
23

3-
export class MockFileSink implements Sink<string, string> {
4-
setPath: (filePath: string) => void;
5-
getPath: () => string;
4+
export class MockFileSink implements WriteAheadLogFile<string> {
65
private writtenItems: string[] = [];
76
private closed = false;
87

8+
constructor(options?: { file?: string; codec?: Codec<string> }) {
9+
const file = options?.file || '/tmp/mock-sink.log';
10+
const codec = options?.codec || {
11+
encode: (input: string) => input,
12+
decode: (data: string) => data,
13+
};
14+
}
15+
16+
#fd: number | null = null;
17+
18+
get path(): string {
19+
return '/tmp/mock-sink.log';
20+
}
21+
22+
getPath(): string {
23+
return this.path;
24+
}
25+
926
open(): void {
10-
this.closed = false;
27+
this.#fd = 1; // Mock file descriptor
1128
}
1229

13-
write(input: string): void {
14-
this.writtenItems.push(input);
30+
append(v: string): void {
31+
this.writtenItems.push(v);
1532
}
1633

1734
close(): void {
35+
this.#fd = null;
1836
this.closed = true;
1937
}
2038

2139
isClosed(): boolean {
22-
return this.closed;
40+
return this.#fd === null;
41+
}
42+
43+
recover(): any {
44+
return {
45+
records: this.writtenItems,
46+
errors: [],
47+
partialTail: null,
48+
};
2349
}
2450

25-
encode(input: string): string {
26-
return `${input}-${this.constructor.name}-encoded`;
51+
repack(): void {
52+
// Mock implementation - do nothing
2753
}
2854

2955
getWrittenItems(): string[] {

packages/utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export {
114114
settlePromise,
115115
} from './lib/promises.js';
116116
export { generateRandomId } from './lib/random.js';
117+
export { profiler } from './lib/profiler/profiler.js';
117118
export {
118119
CODE_PUSHUP_DOMAIN,
119120
CODE_PUSHUP_UNICODE_LOGO,

packages/utils/src/lib/file-sink.ts

Lines changed: 0 additions & 221 deletions
This file was deleted.

0 commit comments

Comments
 (0)