Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description: Abstracted gRPC Stream Event Processing and Enhanced Cursor Management
This PR refactors the existing gRPC streaming code to provide a reusable, abstracted event processing structure and introduces improved cursor management for efficient event handling. The following key changes and improvements have been made:
Key Changes
Abstracted Event Processing with
EventProcessor
InterfaceEventProcessor
abstract base class to decouple the event processing logic from the core gRPC connection and cursor handling.DefaultEventProcessor
, which can be replaced or extended to customize event handling.EventProcessor
.Improved gRPC Connection Management
start_stream
function, making it easier to handle reconnections and manage metadata.RpcError
, with a delay between retry attempts.Cursor Management
save_cursor_to_file
andget_cursor_from_file
to save and retrieve the cursor position, allowing the stream to resume from where it left off.Instructions for Testing
Run the Script:
<package_url>
and<module_name>
with the appropriate values.[start_block]
and[stop_block]
arguments specify the block range.Customize Event Processing:
EventProcessor
and overriding theprocess_event
method.start_stream
.Verify Cursor Handling:
This refactor improves the flexibility, reliability, and maintainability of the gRPC streaming code, making it well-suited for long-running Solana data processing tasks.