Skip to content

Commit

Permalink
feat: keep track of block and indexer cursor (keep-starknet-strange#153)
Browse files Browse the repository at this point in the history
* fixed indexer cursor

* feat: fixed a script.js file

* feat: fixed a docker file

* Cleanup and get cursor persistance working

* Formatting

* Patch indexer script

---------

Co-authored-by: BillXJ <[email protected]>
Co-authored-by: Brandon Roberts <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent 388e987 commit cea2619
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions backend/routes/indexer/route.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package indexer

import (
"fmt"
"net/http"

routeutils "github.com/keep-starknet-strange/art-peace/backend/routes/utils"
Expand Down Expand Up @@ -83,6 +84,10 @@ func consumeIndexerMsg(w http.ResponseWriter, r *http.Request) {
return
}

if len(message.Data.Batch) == 0 {
fmt.Println("No events in batch")
return
}
for _, event := range message.Data.Batch[0].Events {
eventKey := event.Event.Keys[0]
eventProcessor, ok := eventProcessors[eventKey]
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ services:
environment:
- APIBARA_STREAM_URL=http://art-peace-apibara-1:7171
- BACKEND_TARGET_URL=http://art-peace-backend-1:8080/consume-indexer-msg
- PERSIST_TO_REDIS=redis://art-peace-redis-1:6379
- INDEXER_ID=art-peace-indexer-id
volumes:
- configs:/configs
restart: on-failure
Expand Down
3 changes: 2 additions & 1 deletion indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ FROM quay.io/apibara/sink-webhook:0.6.0 as sink-webhook
WORKDIR /indexer
COPY ./indexer/script.js .

CMD ["run", "script.js", "--allow-env", "/configs/configs.env", "--allow-env-from-env", "BACKEND_TARGET_URL,APIBARA_STREAM_URL"]
RUN echo $INDEXER_ID
CMD ["run", "script.js", "--allow-env", "/configs/configs.env", "--allow-env-from-env", "BACKEND_TARGET_URL,APIBARA_STREAM_URL,PERSIST_TO_REDIS,INDEXER_ID", "--allow-net", "--sink-id", "art-peace-sink-id"]
1 change: 0 additions & 1 deletion indexer/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ export const config = {
},
};

// This transform does nothing.
export default function transform(block) {
return block;
}

0 comments on commit cea2619

Please sign in to comment.