-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor storage interface and implement query filtering (#20)
### TL;DR Refactored storage system to support multiple storage instances and improved query filtering. Note that intellisense won't show it if a storageConnector is not implementing the needed interface. But it will throw at runtime. This change was made to not have the switch clause duplicated. If that's not important, we can create multiple functions (one for each interface) so that editors can understand type inference ### What changed? - Introduced `StorageConfig` with separate configurations for Main, Staging, and Orchestrator storage. - Added `QueryFilter` struct for more flexible querying of blocks, transactions, and events. - Updated `IStorage` interface to include separate storage instances for different purposes. - Modified `NewStorageConnector` to create multiple storage instances based on the new config. - Implemented `newConnector` function for type-safe connector creation. - Updated `MemoryConnector` and `ClickHouseConnector` to use the new `QueryFilter` in their query methods. - Added helper functions in `memory.go` for handling query filters and key matching. - Updated `Commiter` to accept a storage instance in its constructor. ### Why make this change? This refactoring improves the flexibility and scalability of the storage system by: 1. Allowing separate storage configurations for different purposes (Main, Staging, Orchestrator). 2. Providing more granular control over queries with the `QueryFilter` struct. 3. Enhancing type safety and reducing potential runtime errors with the new connector creation process. 4. Improving the overall structure and maintainability of the storage-related code.
- Loading branch information
Showing
5 changed files
with
130 additions
and
32 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
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
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
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
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