feat: enhance event filtering and monitoring system

- Add EventTypeFilter for precise event type filtering
- Refactor metrics to track events by type (tx/account/block)
- Add parser caching for improved performance
- Enhance gRPC subscription management
- Update examples and type definitions
This commit is contained in:
ysq
2025-08-16 14:48:51 +08:00
parent 89f4a85a11
commit ea7ecd1d0c
15 changed files with 477 additions and 131 deletions
@@ -0,0 +1,24 @@
use crate::streaming::event_parser::common::{
types::EventType, ACCOUNT_EVENT_TYPES, BLOCK_EVENT_TYPES,
};
#[derive(Debug, Clone)]
pub struct EventTypeFilter {
pub include: Vec<EventType>,
}
impl EventTypeFilter {
pub fn include_transaction_event(&self) -> bool {
self.include
.iter()
.any(|event| !ACCOUNT_EVENT_TYPES.contains(event) && !BLOCK_EVENT_TYPES.contains(event))
}
pub fn include_account_event(&self) -> bool {
self.include.iter().any(|event| ACCOUNT_EVENT_TYPES.contains(event))
}
pub fn include_block_event(&self) -> bool {
self.include.iter().any(|event| BLOCK_EVENT_TYPES.contains(event))
}
}
+1
View File
@@ -1,5 +1,6 @@
pub mod types;
pub mod utils;
pub mod filter;
/// 自动生成UnifiedEvent trait实现的宏
#[macro_export]
@@ -180,6 +180,24 @@ pub enum EventType {
Unknown,
}
pub const ACCOUNT_EVENT_TYPES: &[EventType] = &[
EventType::AccountRaydiumAmmV4AmmInfo,
EventType::AccountPumpSwapGlobalConfig,
EventType::AccountPumpSwapPool,
EventType::AccountBonkPoolState,
EventType::AccountBonkGlobalConfig,
EventType::AccountBonkPlatformConfig,
EventType::AccountBonkVestingRecord,
EventType::AccountPumpFunBondingCurve,
EventType::AccountPumpFunGlobal,
EventType::AccountRaydiumClmmAmmConfig,
EventType::AccountRaydiumClmmPoolState,
EventType::AccountRaydiumClmmTickArrayState,
EventType::AccountRaydiumCpmmAmmConfig,
EventType::AccountRaydiumCpmmPoolState,
];
pub const BLOCK_EVENT_TYPES: &[EventType] = &[EventType::BlockMeta];
impl EventType {
#[allow(clippy::inherent_to_string)]
pub fn to_string(&self) -> String {