{"id":31037070,"url":"https://github.com/0xfnzero/fzstream-client","last_synced_at":"2025-09-14T04:48:40.635Z","repository":{"id":310396063,"uuid":"1039664825","full_name":"0xfnzero/fzstream-client","owner":"0xfnzero","description":"fzstream client","archived":false,"fork":false,"pushed_at":"2025-09-02T12:08:23.000Z","size":122,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-02T14:19:11.552Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xfnzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-17T18:10:48.000Z","updated_at":"2025-09-02T12:08:26.000Z","dependencies_parsed_at":"2025-08-17T21:24:56.834Z","dependency_job_id":"57caba40-5d3c-4690-b899-f785cdfb68eb","html_url":"https://github.com/0xfnzero/fzstream-client","commit_stats":null,"previous_names":["0xfnzero/fzstream-client"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/0xfnzero/fzstream-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Ffzstream-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Ffzstream-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Ffzstream-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Ffzstream-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xfnzero","download_url":"https://codeload.github.com/0xfnzero/fzstream-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xfnzero%2Ffzstream-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275062963,"owners_count":25398888,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-14T04:48:38.391Z","updated_at":"2025-09-14T04:48:40.623Z","avatar_url":"https://github.com/0xfnzero.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FZStream Client SDK\n\n[![Crates.io](https://img.shields.io/crates/v/fzstream-client)](https://crates.io/crates/fzstream-client)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Rust](https://github.com/0xfnzero/fz-stream-client/workflows/Rust/badge.svg)](https://github.com/0xfnzero/fz-stream-client/actions)\n\n一个高性能的 QUIC 客户端 SDK，专为实时 Solana 事件流设计。\n\n## ✨ 特性\n\n- **超低延迟**: 优化的 QUIC 协议实现\n- **多协议支持**: JSON 和 Bincode 序列化\n- **压缩算法**: LZ4 和 Zstd 压缩支持\n- **自动重连**: 智能重连机制，支持指数退避\n- **事件驱动**: 基于回调的事件处理\n- **性能监控**: 内置统计和指标\n- **多协议事件**: 支持 PumpFun、PumpSwap、Bonk、Raydium 等协议\n\n## 🚀 快速开始\n\n### 安装\n\n在 `Cargo.toml` 中添加依赖：\n\n```toml\n[dependencies]\nfzstream-client = {\"0.1.0\"}\n```\n\n### 基本使用\n\n```rust\nuse anyhow::Result;\nuse fzstream_client::{FzStreamClient, StreamClientConfig};\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c()\u003e {\n    // 初始化日志\n    env_logger::init();\n    \n    // 配置客户端\n    let mut config = StreamClientConfig::default();\n    config.endpoint = \"127.0.0.1:2222\".to_string();\n    config.auth_token = Some(\"demo_token_12345\".to_string());\n    \n    let mut client = FzStreamClient::with_config(config);\n    \n    // 连接到服务器\n    client.connect().await?;\n    \n    // 订阅事件\n    client.subscribe_events(|unified_event| {\n        let event_type = unified_event.event_type();\n        let event_id = unified_event.id();\n        println!(\"收到事件 [{}]: {:?}\", event_id, event_type);\n    }).await?;\n    \n    // 保持运行直到 Ctrl+C\n    tokio::signal::ctrl_c().await?;\n    \n    // 关闭连接\n    client.shutdown().await?;\n    Ok(())\n}\n```\n\n## 📖 高级用法\n\n### 详细事件处理\n\n```rust\nuse solana_streamer_sdk::streaming::event_parser::protocols::{bonk, pumpfun, pumpswap};\n\n// 使用 match_event 宏处理特定事件类型\nmacro_rules! match_event {\n    ($event:expr, {\n        $($event_type:ident =\u003e |$e:ident: $event_struct:ty| $body:block,)*\n        _ =\u003e $default:block\n    }) =\u003e {\n        $(\n            if let Some($e) = $event.as_any().downcast_ref::\u003c$event_struct\u003e() {\n                $body\n                return;\n            }\n        )*\n        $default\n    };\n}\n\nclient.subscribe_events(|unified_event| {\n    match_event!(unified_event, {\n        PumpFunTradeEvent =\u003e |e: pumpfun::PumpFunTradeEvent| {\n            println!(\"PumpFun 交易: {} at {}\", e.metadata.signature, e.metadata.block_time);\n        },\n        BonkTradeEvent =\u003e |e: bonk::BonkTradeEvent| {\n            println!(\"Bonk 交易: {}\", e.metadata.signature);\n        },\n        _ =\u003e {\n            println!(\"其他事件类型: {:?}\", unified_event.event_type());\n        }\n    });\n}).await?;\n```\n\n### 连接状态监控\n\n```rust\nuse fzstream_client::ConnectionStatus;\n\n// 监控连接状态变化\nclient.on_status_change(|status| {\n    match status {\n        ConnectionStatus::Connected =\u003e println!(\"已连接\"),\n        ConnectionStatus::Streaming =\u003e println!(\"开始流式传输\"),\n        ConnectionStatus::Error(msg) =\u003e println!(\"连接错误: {}\", msg),\n        _ =\u003e {}\n    }\n});\n```\n\n## ⚙️ 配置选项\n\n### StreamClientConfig\n\n```rust\nuse std::time::Duration;\nuse fzstream_client::StreamClientConfig;\n\nlet config = StreamClientConfig {\n    endpoint: \"127.0.0.1:2222\".to_string(),\n    server_name: \"localhost\".to_string(),\n    auth_token: Some(\"your_auth_token\".to_string()),\n    auto_reconnect: true,\n    reconnect_interval: Duration::from_secs(5),\n    max_reconnect_attempts: 10,\n    connection_timeout: Duration::from_secs(10),\n    keep_alive_interval: Duration::from_secs(30),\n    reconnect_backoff_multiplier: 1.5,\n    max_reconnect_backoff: Duration::from_secs(60),\n};\n```\n\n| 配置项 | 类型 | 默认值 | 描述 |\n|--------|------|--------|------|\n| `endpoint` | `String` | `\"127.0.0.1:2222\"` | 服务器地址 |\n| `server_name` | `String` | `\"localhost\"` | 服务器名称 |\n| `auth_token` | `Option\u003cString\u003e` | `None` | 认证令牌 |\n| `auto_reconnect` | `bool` | `true` | 是否自动重连 |\n| `reconnect_interval` | `Duration` | `5s` | 重连间隔 |\n| `max_reconnect_attempts` | `u32` | `10` | 最大重连次数 |\n| `connection_timeout` | `Duration` | `10s` | 连接超时 |\n| `keep_alive_interval` | `Duration` | `30s` | 保活间隔 |\n| `reconnect_backoff_multiplier` | `f64` | `1.5` | 重连退避倍数 |\n| `max_reconnect_backoff` | `Duration` | `60s` | 最大重连退避时间 |\n\n## 🔧 API 参考\n\n### FzStreamClient\n\n#### 主要方法\n\n- `connect()` - 连接到服务器\n- `subscribe_events(handler)` - 订阅事件流\n- `on_status_change(handler)` - 监控连接状态\n- `shutdown()` - 关闭连接\n\n### 支持的事件类型\n\n- **PumpFun 协议**:\n  - `PumpFunTradeEvent` - 交易事件\n  - `PumpFunCreateTokenEvent` - 创建代币事件\n  - `PumpFunMigrateEvent` - 迁移事件\n\n- **PumpSwap 协议**:\n  - `PumpSwapBuyEvent` - 买入事件\n  - `PumpSwapSellEvent` - 卖出事件\n  - `PumpSwapCreatePoolEvent` - 创建池事件\n\n- **Bonk 协议**:\n  - `BonkTradeEvent` - 交易事件\n  - `BonkPoolCreateEvent` - 池创建事件\n\n- **Raydium 协议**:\n  - `RaydiumCpmmSwapEvent` - CPMM 交换事件\n  - `RaydiumAmmV4SwapEvent` - AMM V4 交换事件\n  - `RaydiumClmmSwapEvent` - CLMM 交换事件\n\n- **区块元数据**:\n  - `BlockMetaEvent` - 区块元数据事件\n\n## 🚀 性能特性\n\n- **超低延迟**: 基于 QUIC 协议，延迟通常在毫秒级别\n- **高吞吐量**: 支持大量并发连接和事件处理\n- **自动重连**: 网络中断时自动重连，支持指数退避\n- **压缩支持**: 内置 LZ4 和 Zstd 压缩，减少网络传输\n- **内存优化**: 高效的内存管理和垃圾回收\n\n## 🔍 故障排除\n\n### 常见问题\n\n1. **连接失败**\n   ```bash\n   # 检查服务器是否运行\n   cargo run --release\n   \n   # 检查端口是否正确\n   netstat -an | grep 2222\n   ```\n\n2. **认证失败**\n   ```rust\n   // 确保使用正确的认证令牌\n   config.auth_token = Some(\"your_correct_token\".to_string());\n   ```\n\n3. **事件接收问题**\n   ```rust\n   // 启用详细日志\n   std::env::set_var(\"RUST_LOG\", \"debug\");\n   env_logger::init();\n   ```\n\n### 日志级别\n\n- `error`: 错误信息\n- `warn`: 警告信息  \n- `info`: 一般信息\n- `debug`: 调试信息\n- `trace`: 详细跟踪信息\n\n## 📄 许可证\n\n本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。\n\n## 🤝 贡献\n\n欢迎提交 Issue 和 Pull Request！\n\n## 📞 支持\n\n- GitHub Issues: [https://github.com/0xfnzero/fz-stream-client/issues](https://github.com/0xfnzero/fz-stream-client/issues)\n- 邮箱: byteblock6@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfnzero%2Ffzstream-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xfnzero%2Ffzstream-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xfnzero%2Ffzstream-client/lists"}