Skip to content
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

refactor: Introduce struct to manager persistent indexer state #727

Merged
merged 12 commits into from
May 12, 2024

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented May 9, 2024

This PR centralises persistent Indexer State within the IndexerStateManager struct. Currently, we only persist the "stream version", but this will soon grow to "enabled/disabled", which will be implemented in my next PR. This is just a tidy up to make the next step a bit easier.

Indexer state will be stored as stringified JSON under {account_id}/{function_name}:state, currently this only includes when the block stream was last synced. I've included a migration step in to move from the old key/structure to the new.

@morgsmccauley morgsmccauley linked an issue May 9, 2024 that may be closed by this pull request
@@ -52,9 +55,18 @@ async fn main() -> anyhow::Result<()> {
loop {
let indexer_registry = registry.fetch().await?;

indexer_state_manager
.migrate_state_if_needed(&indexer_registry)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrating "stream versions" to new indexer state objects

pub async fn is_migration_complete(&self) -> anyhow::Result<Option<bool>>;
}

impl Clone for RedisClientImpl {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to manually mock RedisClient so Clone is available on the mock object.

@morgsmccauley morgsmccauley marked this pull request as ready for review May 9, 2024 21:37
@morgsmccauley morgsmccauley requested a review from a team as a code owner May 9, 2024 21:37
@morgsmccauley morgsmccauley merged commit 702fe46 into main May 12, 2024
4 checks passed
@morgsmccauley morgsmccauley deleted the feat/indexer-state branch May 12, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to manually suspend indexers
2 participants