-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,66 @@ | ||
# Indexer Service | ||
|
||
This service is a way to index on any event on the blockchain via an API. | ||
This service is a way to create indexers on-demand using [apibara](https://www.apibara.com/docs). | ||
|
||
 | ||
 | ||
[](https://codecov.io/gh/Astraly-Labs/indexer-service) | ||
|
||
## Architecture | ||
|
||
 | ||
```mermaid | ||
sequenceDiagram | ||
title Architecture | ||
## Setup | ||
actor User | ||
participant Indexer Service | ||
participant S3 | ||
participant Database | ||
participant Child Process | ||
1. Set AWS environment variables | ||
2. Download the bin file | ||
User->>Indexer Service: POST / {script.js} | ||
rect rgb(200, 200, 240) | ||
note right of User: transaction | ||
Indexer Service->>S3: Save script.js to S3 | ||
S3-->>Indexer Service: ok | ||
Indexer Service->>Database: Create indexer in CREATED state | ||
Database-->>Indexer Service: ok | ||
end | ||
Indexer Service->>S3: get script | ||
S3-->>Indexer Service: script | ||
Indexer Service->>Child Process: start apibara indexing with binary | ||
Child Process-->>Indexer Service: ok | ||
Indexer Service->>Database: update indexer process id | ||
Database-->>Indexer Service: ok | ||
Indexer Service-->>User: ok | ||
alt indexer fails | ||
Child Process->>Indexer Service: service failed | ||
Indexer Service->>Database: mark indexer with id X as FailedRunning | ||
Database-->>Indexer Service: ok | ||
else indexer is stopped | ||
User->>Indexer Service: /stop/:id | ||
Indexer Service->>Database: get process id | ||
Database-->>Indexer Service: process id | ||
Indexer Service->>Child Process: terminate | ||
Child Process-->>Indexer Service: ok | ||
Indexer Service->>Database: mark as FailedStopping | ||
Database-->>Indexer Service: ok | ||
Indexer Service-->>User: ok | ||
else start a previously stopped indexer | ||
User->>Indexer Service: /start/:id | ||
Indexer Service->>S3: get script | ||
S3-->>Indexer Service: script | ||
Indexer Service->>Child Process: start | ||
Child Process-->>Indexer Service: ok | ||
Indexer Service->>Database: mark as Running and update process Id | ||
Database-->>Indexer Service: ok | ||
Indexer Service-->>User: ok | ||
end | ||
``` | ||
|
||
## Running tests | ||
|
||
1. Run docker compose `docker compose -f compose.dev.yaml up --build` | ||
|
||
2. Run tests with `cargo nextest run --test-threads=1` |
Binary file not shown.
This file was deleted.
Oops, something went wrong.