mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-16 02:18:05 +00:00
refactor: overhaul event parser architecture for better performance
- Centralize event parsing logic and remove factory pattern - Add high-performance clock module to reduce latency - Consolidate protocol parsers with unified interface - Introduce account pubkey caching and streamline traits - Remove deprecated macro-based and multi-protocol implementations
This commit is contained in:
@@ -13,10 +13,8 @@ use crate::streaming::event_parser::common::filter::EventTypeFilter;
|
||||
use crate::streaming::event_parser::core::account_event_parser::AccountEventParser;
|
||||
use crate::streaming::event_parser::core::common_event_parser::CommonEventParser;
|
||||
|
||||
use crate::streaming::event_parser::EventParser;
|
||||
use crate::streaming::event_parser::{
|
||||
core::traits::UnifiedEvent, protocols::mutil::parser::MutilEventParser, Protocol,
|
||||
};
|
||||
use crate::streaming::event_parser::core::event_parser::EventParser;
|
||||
use crate::streaming::event_parser::{core::traits::UnifiedEvent, Protocol};
|
||||
use crate::streaming::grpc::{BackpressureConfig, EventPretty};
|
||||
use crate::streaming::shred::TransactionWithSlot;
|
||||
use once_cell::sync::OnceCell;
|
||||
@@ -25,7 +23,7 @@ use once_cell::sync::OnceCell;
|
||||
pub struct EventProcessor {
|
||||
pub(crate) metrics_manager: MetricsManager,
|
||||
pub(crate) config: ClientConfig,
|
||||
pub(crate) parser_cache: OnceCell<Arc<dyn EventParser>>,
|
||||
pub(crate) parser_cache: OnceCell<Arc<EventParser>>,
|
||||
pub(crate) protocols: Vec<Protocol>,
|
||||
pub(crate) event_type_filter: Option<EventTypeFilter>,
|
||||
pub(crate) callback: Option<Arc<dyn Fn(Box<dyn UnifiedEvent>) + Send + Sync>>,
|
||||
@@ -77,7 +75,7 @@ impl EventProcessor {
|
||||
let protocols_ref = &self.protocols;
|
||||
let event_type_filter_ref = self.event_type_filter.as_ref();
|
||||
self.parser_cache.get_or_init(|| {
|
||||
Arc::new(MutilEventParser::new(protocols_ref.clone(), event_type_filter_ref.cloned()))
|
||||
Arc::new(EventParser::new(protocols_ref.clone(), event_type_filter_ref.cloned()))
|
||||
});
|
||||
|
||||
if matches!(self.backpressure_config.strategy, BackpressureStrategy::Block) {
|
||||
@@ -85,7 +83,7 @@ impl EventProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_parser(&self) -> Arc<dyn EventParser> {
|
||||
pub fn get_parser(&self) -> Arc<EventParser> {
|
||||
self.parser_cache.get().unwrap().clone()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user