Skip to content

Commit

Permalink
Add production field to data messages (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek authored Jan 18, 2025
2 parents f1c0092 + 4f827ba commit c806dcc
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "protocol: add data production field",
"packageName": "@apibara/indexer",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "protocol: add data production field",
"packageName": "@apibara/plugin-drizzle",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "protocol: add data production field",
"packageName": "@apibara/plugin-mongo",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "protocol: add data production field",
"packageName": "@apibara/plugin-sqlite",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add data production field to data messages",
"packageName": "@apibara/protocol",
"email": "[email protected]",
"dependentChangeType": "patch"
}
6 changes: 4 additions & 2 deletions examples/starknet-client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ const command = defineCommand({
filter: [filter],
finality: "accepted",
startingCursor: {
orderKey: 800_000n,
orderKey: 1_078_335n,
},
});

for await (const message of client.streamData(request)) {
for await (const message of client.streamData(request, {
timeout: 40_000,
})) {
switch (message._tag) {
case "data": {
consola.info("Data", message.data.endCursor?.orderKey);
Expand Down
16 changes: 16 additions & 0 deletions packages/indexer/src/indexer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ describe("Run Test", () => {
cursor: { orderKey: 100n },
endCursor: { orderKey: 101n },
data: [null, null],
production: "backfill",
},
},
{
Expand All @@ -140,6 +141,7 @@ describe("Run Test", () => {
cursor: { orderKey: 101n },
endCursor: { orderKey: 102n },
data: [null, null],
production: "backfill",
},
},
{
Expand All @@ -149,6 +151,7 @@ describe("Run Test", () => {
cursor: { orderKey: 102n },
endCursor: { orderKey: 103n },
data: [{ data: "B" }, null],
production: "backfill",
},
},
];
Expand All @@ -165,6 +168,7 @@ describe("Run Test", () => {
cursor: { orderKey: 102n },
endCursor: { orderKey: 103n },
data: [{ data: "B" }, { data: "103B" }],
production: "backfill",
},
},
{
Expand All @@ -174,6 +178,7 @@ describe("Run Test", () => {
cursor: { orderKey: 103n },
endCursor: { orderKey: 104n },
data: [null, { data: "104B" }],
production: "backfill",
},
},
{
Expand All @@ -183,6 +188,7 @@ describe("Run Test", () => {
cursor: { orderKey: 104n },
endCursor: { orderKey: 105n },
data: [null, { data: "105B" }],
production: "backfill",
},
},
{
Expand All @@ -192,6 +198,7 @@ describe("Run Test", () => {
cursor: { orderKey: 105n },
endCursor: { orderKey: 106n },
data: [{ data: "C" }, { data: "106B" }],
production: "backfill",
},
},
];
Expand All @@ -208,6 +215,7 @@ describe("Run Test", () => {
cursor: { orderKey: 105n },
endCursor: { orderKey: 106n },
data: [{ data: "C" }, { data: "106BC" }],
production: "backfill",
},
},
{
Expand All @@ -217,6 +225,7 @@ describe("Run Test", () => {
cursor: { orderKey: 106n },
endCursor: { orderKey: 107n },
data: [null, { data: "107BC" }],
production: "backfill",
},
},
{
Expand All @@ -226,6 +235,7 @@ describe("Run Test", () => {
cursor: { orderKey: 107n },
endCursor: { orderKey: 108n },
data: [null, { data: "108BC" }],
production: "backfill",
},
},
];
Expand Down Expand Up @@ -318,6 +328,7 @@ describe("Run Test", () => {
cursor: { orderKey: 100n },
endCursor: { orderKey: 101n },
data: [null, null],
production: "backfill",
},
},
{
Expand All @@ -327,6 +338,7 @@ describe("Run Test", () => {
cursor: { orderKey: 101n },
endCursor: { orderKey: 102n },
data: [null, null],
production: "backfill",
},
},
{
Expand All @@ -336,6 +348,7 @@ describe("Run Test", () => {
cursor: { orderKey: 102n },
endCursor: { orderKey: 103n },
data: [{ data: "B" }, null],
production: "backfill",
},
},
Error("this error should not occurr!"),
Expand All @@ -354,6 +367,7 @@ describe("Run Test", () => {
cursor: { orderKey: 103n },
endCursor: { orderKey: 104n },
data: [null, { data: "104B" }],
production: "backfill",
},
},
{
Expand All @@ -363,6 +377,7 @@ describe("Run Test", () => {
cursor: { orderKey: 104n },
endCursor: { orderKey: 105n },
data: [null, { data: "105B" }],
production: "backfill",
},
},
{
Expand All @@ -372,6 +387,7 @@ describe("Run Test", () => {
cursor: { orderKey: 105n },
endCursor: { orderKey: 106n },
data: [{ data: "C" }, { data: "106B" }],
production: "backfill",
},
},
];
Expand Down
1 change: 1 addition & 0 deletions packages/indexer/src/internal/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function generateMockMessages(
finality: "accepted",
data: [{ data: `${5_000_000 + i}` }],
endCursor: { orderKey: BigInt(5_000_000 + i) },
production: "backfill",
},
});
}
Expand Down
Loading

0 comments on commit c806dcc

Please sign in to comment.