Skip to content

Commit

Permalink
fix: readme
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt committed Feb 18, 2025
1 parent 9c7a927 commit 3c70a18
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 57 deletions.
60 changes: 53 additions & 7 deletions README.md
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).

![codebuild](https://codebuild.eu-west-3.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiTUtmdVdqUjg2cTJnN2dxZlZ3R0Z2Z0E4NG8vcHZyUnovdzBrTFFSWm1heUdoWE0reTRkOXVQT1E0alZxTHZTNzcxL3I3YkNyZ3Z6VmtMMFhvM2V6NGxZPSIsIml2UGFyYW1ldGVyU3BlYyI6IjhNRHUxbXNhaTNKcmlBNTEiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=main)
![build workflow](https://github.com/astraly-labs/indexer-service/actions/workflows/rust-build.yml/badge.svg)
[![codecov](https://codecov.io/gh/Astraly-Labs/indexer-service/graph/badge.svg?token=3XLJIJBnzM)](https://codecov.io/gh/Astraly-Labs/indexer-service)

## Architecture

![sequence_architecture.png](docs/sequence_architecture.png)
```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 removed docs/sequence_architecture.jpg
Binary file not shown.
50 changes: 0 additions & 50 deletions docs/sequence_architecture.txt

This file was deleted.

0 comments on commit 3c70a18

Please sign in to comment.