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

DPLT-1074 Queue real-time messages on Redis Streams #157

Merged
merged 3 commits into from
Aug 1, 2023

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented Jul 31, 2023

This PR adds a subset of the IndexerQueueMessages to a Redis Stream dedicated to that indexer.

@morgsmccauley morgsmccauley requested a review from a team as a code owner July 31, 2023 03:30
key: &str,
fields: &[(&str, impl ToRedisArgs + std::fmt::Debug)],
) -> anyhow::Result<()> {
sadd(redis_connection_manager, STREAMS_SET_KEY, key).await?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using a set to track the complete list of streams as it is not straight forward to query them directly

tracing::debug!(target: STORAGE, "XADD: {}, {:?}", stream_key, fields);

// TODO: Remove stream cap when we finally start processing it
redis::cmd("XTRIM")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As we have nothing processing/removing these messages I'm adding a limit to avoid hitting the memory limit of Redis

@@ -195,6 +195,20 @@ async fn handle_streamer_message(
if !indexer_function.provisioned {
set_provisioned_flag(&mut indexer_registry_locked, &indexer_function);
}

storage::set(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Only adding a subset of the data for now. This will definitely evolve over time and we'll need to have a decent think around where each piece belongs; on the stream on in storage.

I'm specifically trying to avoid cases where the 'static' data changes and is read immediately, but it corresponds to a block height later in the stream.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could set it in the same places as the in memory registry: on startup and update when the indexer_registry.index_and_process_register_calls function detects a change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, I'll look in to it 👍🏼

@morgsmccauley morgsmccauley merged commit d2f44e8 into main Aug 1, 2023
3 checks passed
@morgsmccauley morgsmccauley deleted the DPLT-1074-write-real-time-messages-to-redis branch August 1, 2023 19:57
morgsmccauley added a commit that referenced this pull request Aug 1, 2023
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.

2 participants