-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add reloadIndexer() & async support for indexer constructor & record reorgs #188
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
Merged
fracek
merged 15 commits into
apibara:main
from
jaipaljadeja:feat/qol-improvements-fixes
Nov 19, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
edae0f2
cli: add async support for indexer constructor
jaipaljadeja 159b097
examples: add async indexer example
jaipaljadeja 38d0041
cli: add `reloadIndexer()` helper
jaipaljadeja fc5037e
plugin-drizzle: fix test
jaipaljadeja 24a6cf0
indexer: update reloadIndexer() logic with context
jaipaljadeja bb29372
indexer: add reloadIfNeeded helper
jaipaljadeja 3f19efd
indexer: add abort signal when indexer stops
jaipaljadeja 0b03fb6
example: add async indexer example
jaipaljadeja a19e6ea
indexer: add missing abort signal
jaipaljadeja 2684c91
indexer: fix potential abort controller bug
jaipaljadeja a7f23d6
indexer: run:after hook should be called outside loop
jaipaljadeja 03e0304
plugin-drizzle: add record reorgs and fix invalidation bug
jaipaljadeja 6536bf9
indexer: support for multiple invalidate and finalize messages in ge…
jaipaljadeja 457a540
plugin-drizzle: add reorg tests
jaipaljadeja 375932b
Change files
jaipaljadeja 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
7 changes: 7 additions & 0 deletions
7
change/@apibara-indexer-83b5b6e9-bb8f-4836-a8eb-7d00e8d67695.json
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "indexer: update reloadIndexer() logic with context and update generateMockMessages()", | ||
| "packageName": "@apibara/indexer", | ||
| "email": "jadejajaipal5@gmail.com", | ||
| "dependentChangeType": "patch" | ||
| } |
7 changes: 7 additions & 0 deletions
7
change/@apibara-plugin-drizzle-e151f0cd-f880-46b2-8bdd-ade847e4f2ca.json
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "plugin-drizzle: add record reorgs option and forward original error", | ||
| "packageName": "@apibara/plugin-drizzle", | ||
| "email": "jadejajaipal5@gmail.com", | ||
| "dependentChangeType": "patch" | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "prerelease", | ||
| "comment": "cli: add reloadIndexer() and async support for indexer constructors", | ||
| "packageName": "apibara", | ||
| "email": "jadejajaipal5@gmail.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
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 |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { StarknetStream } from "@apibara/starknet"; | ||
| import { defineIndexer } from "apibara/indexer"; | ||
| import { useLogger } from "apibara/plugins"; | ||
| import type { ApibaraRuntimeConfig } from "apibara/types"; | ||
| import { hash } from "starknet"; | ||
|
|
||
| export default async function (runtimeConfig: ApibaraRuntimeConfig) { | ||
| const { | ||
| starknet: { startingBlock }, | ||
| } = runtimeConfig; | ||
fracek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Simulating a API call that takes 500 ms | ||
| await new Promise((resolve) => setTimeout(resolve, 500)); | ||
|
|
||
| return defineIndexer(StarknetStream)({ | ||
| streamUrl: "https://mainnet.starknet.a5a.ch", | ||
| finality: "accepted", | ||
| startingBlock: BigInt(startingBlock), | ||
| filter: { | ||
| events: [ | ||
| { | ||
| address: | ||
| "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8" as `0x${string}`, | ||
| keys: [hash.getSelectorFromName("Transfer") as `0x${string}`], | ||
| }, | ||
| ], | ||
| }, | ||
| hooks: { | ||
| "run:before": ({ abortSignal }) => { | ||
| // const logger = useLogger(); | ||
| // logger.info("=== FILE WATCHER SET UP ==="); | ||
| // watch("./tmp/test", { signal: abortSignal, }, (eventType, filename) => { | ||
| // logger.info("=== FILE CHANGED ==="); | ||
| // reloadIndexer(); | ||
| // }); | ||
| }, | ||
| }, | ||
| async transform({ endCursor, finality }) { | ||
| const logger = useLogger(); | ||
|
|
||
| logger.info( | ||
| "Transforming block | orderKey: ", | ||
| endCursor?.orderKey, | ||
| " | finality: ", | ||
| finality, | ||
| ); | ||
|
|
||
| await new Promise((resolve) => setTimeout(resolve, 3000)); | ||
| }, | ||
| }); | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -82,4 +82,4 @@ | |
| "peerDependencies": { | ||
| "vitest": "^1.6.0" | ||
| } | ||
| } | ||
| } | ||
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,2 +1,3 @@ | ||
| export * from "./indexer"; | ||
| export { useIndexerContext } from "./context"; | ||
| export { reloadIndexer, ReloadIndexerRequest } from "./utils"; |
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.
Uh oh!
There was an error while loading. Please reload this page.