-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- upgrade sink interface - add sink and its transaction to indexer context - add drizzle sink for postgres - update csv, sqlite sink - add `useSink` hook - update indexer examples - update persistence and kv plugin - update vcr and tests
- Loading branch information
Showing
29 changed files
with
701 additions
and
327 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,14 +1,19 @@ | ||
import { AsyncLocalStorage } from "node:async_hooks"; | ||
import { getContext } from "unctx"; | ||
import type { Sink } from "./sink"; | ||
|
||
// biome-ignore lint/suspicious/noExplicitAny: context type | ||
export interface IndexerContext extends Record<string, any> {} | ||
export interface IndexerContext<TTxnParams = any> extends Record<string, any> { | ||
sink?: Sink<TTxnParams>; | ||
sinkTransaction?: TTxnParams; | ||
} | ||
|
||
export const indexerAsyncContext = getContext<IndexerContext>("indexer", { | ||
asyncContext: true, | ||
AsyncLocalStorage, | ||
}); | ||
|
||
export function useIndexerContext() { | ||
return indexerAsyncContext.use(); | ||
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | ||
export function useIndexerContext<TTxnParams = any>() { | ||
return indexerAsyncContext.use() as IndexerContext<TTxnParams>; | ||
} |
This file contains 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,2 @@ | ||
export * from "./useKVStore"; | ||
export * from "./useSink"; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { IndexerContext } from "../context"; | ||
|
||
export function useSink<TTxnParams>({ | ||
context, | ||
}: { | ||
context: IndexerContext<TTxnParams>; | ||
}) { | ||
if (!context.sinkTransaction) { | ||
throw new Error("Transaction context doesn't exist!"); | ||
} | ||
|
||
return context.sinkTransaction; | ||
} |
This file contains 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.