-
Notifications
You must be signed in to change notification settings - Fork 15
feat(utils): add WriteAheadLog classes #1210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
BioPhoton
wants to merge
41
commits into
main
Choose a base branch
from
feat/utils/file-sink
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
c03b2c4
refactor: add general file sink logic
756f8c0
feat: add file sink classes
4c95897
Merge branch 'main' into feat/utils/file-sink
b0c9cc4
refactor: add trace json file
1f6e326
refactor: wip
6bcb73b
refactor: wip
dfb43be
Merge remote-tracking branch 'origin/main' into feat/utils/file-sink
3fe6871
refactor: wip arc
BioPhoton 67e004c
refactor: fix lint
BioPhoton a4a9f10
Merge branch 'main' into feat/utils/file-sink
BioPhoton 0b1fd3a
refactor: wip
BioPhoton bf0ecb9
refactor: wip
BioPhoton c88ffe9
refactor: wip
BioPhoton d6e75e6
refactor: wip
BioPhoton 21575b3
refactor: wip
BioPhoton 09437a9
refactor: wip
BioPhoton 4705394
refactor: wip
BioPhoton e0c210e
refactor: wip
BioPhoton 29016b0
refactor: wip
BioPhoton e60ea2b
refactor: wip
BioPhoton 5ea2ac4
refactor: wip
BioPhoton 73ff371
refactor: wip
BioPhoton 34b0eb8
refactor: wip
BioPhoton dd2e959
refactor: fix lint
BioPhoton 64501ec
refactor: fix tests
BioPhoton eb559f5
refactor: add tests
BioPhoton e20e804
refactor: wip
BioPhoton 8f812c5
refactor: wip
BioPhoton a839b9b
refactor: fix lint
BioPhoton 27b1506
refactor: fix lint
BioPhoton 592fb89
refactor: wip
BioPhoton a19070e
refactor: wip
BioPhoton 4f8cd2d
refactor: wip
BioPhoton bc86d08
refactor: wip
BioPhoton a530134
refactor: wip
BioPhoton d9eb84b
refactor: remove path logic
BioPhoton 67f0c1e
refactor: fix lint
BioPhoton a3641d3
refactor: fix unit tests on windows
BioPhoton f7bf8e8
Update packages/utils/src/lib/wal.ts
BioPhoton d658b0f
Update packages/utils/src/lib/wal.ts
BioPhoton f34ef73
Update packages/utils/src/lib/wal.ts
BioPhoton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,62 @@ | ||
| import type { Sink } from '../src/lib/sink-source.type'; | ||
| import { WriteAheadLogFile } from '../src/lib/wal.js'; | ||
| import type { Codec } from '../src/lib/wal.js'; | ||
|
|
||
| export class MockSink implements Sink<string, string> { | ||
| export class MockFileSink implements WriteAheadLogFile<string> { | ||
|
Check failure on line 4 in packages/utils/mocks/sink.mock.ts
|
||
| private writtenItems: string[] = []; | ||
| private closed = false; | ||
|
|
||
| constructor(options?: { file?: string; codec?: Codec<string> }) { | ||
| const file = options?.file || '/tmp/mock-sink.log'; | ||
| const codec = options?.codec || { | ||
| encode: (input: string) => input, | ||
| decode: (data: string) => data, | ||
| }; | ||
| } | ||
|
|
||
| #fd: number | null = null; | ||
|
|
||
| get path(): string { | ||
| return '/tmp/mock-sink.log'; | ||
| } | ||
|
|
||
| getPath(): string { | ||
| return this.path; | ||
| } | ||
|
|
||
| open(): void { | ||
| this.closed = false; | ||
| this.#fd = 1; // Mock file descriptor | ||
| } | ||
|
|
||
| write(input: string): void { | ||
| this.writtenItems.push(input); | ||
| append(v: string): void { | ||
| this.writtenItems.push(v); | ||
| } | ||
|
|
||
| close(): void { | ||
| this.#fd = null; | ||
| this.closed = true; | ||
| } | ||
|
|
||
| isClosed(): boolean { | ||
| return this.closed; | ||
| return this.#fd === null; | ||
| } | ||
|
|
||
| recover(): any { | ||
| return { | ||
| records: this.writtenItems, | ||
| errors: [], | ||
| partialTail: null, | ||
| }; | ||
| } | ||
|
|
||
| encode(input: string): string { | ||
| return `${input}-${this.constructor.name}-encoded`; | ||
| repack(): void { | ||
| // Mock implementation - do nothing | ||
| } | ||
|
|
||
| getWrittenItems(): string[] { | ||
| return [...this.writtenItems]; | ||
| } | ||
|
|
||
| clearWrittenItems(): void { | ||
| this.writtenItems = []; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| export const PROFILER_ENABLED_ENV_VAR = 'CP_PROFILING'; | ||
| export const PROFILER_COORDINATOR_FLAG_ENV_VAR = 'CP_PROFILER_COORDINATOR'; | ||
| export const PROFILER_ORIGIN_PID_ENV_VAR = 'CP_PROFILER_ORIGIN_PID'; | ||
| export const PROFILER_DIRECTORY_ENV_VAR = 'CP_PROFILER_DIR'; | ||
| export const PROFILER_BASE_NAME = 'trace'; | ||
| export const PROFILER_DIRECTORY = './tmp/profiles'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The TypeScript plugin reports an error here. Maybe
MockFileSinkshould implementAppendableSink<string>instead?