diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f4b52a --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +Example config: + +```json +{ + "public_ip": "127.0.0.1", + "local_ip": "0.0.0.0", + "port": 30000, + "network": { + "quic": null, + "connection_manager_channel_capacity": 128, + "connectivity_check_interval": "5s", + "max_frame_size": 104857600, + "connect_timeout": "10s", + "connection_backoff": "10s", + "max_connection_backoff": "1m", + "connection_error_delay": "3s", + "max_concurrent_outstanding_connections": 100, + "max_concurrent_connections": null, + "active_peers_event_channel_capacity": 128, + "shutdown_idle_timeout": "1m", + "enable_0rtt": false + }, + "dht": { + "max_k": 6, + "max_peer_info_ttl": "1h", + "max_stored_value_ttl": "1h", + "max_storage_capacity": 10000, + "storage_item_time_to_idle": null, + "local_info_refresh_period": "1m", + "local_info_announce_period": "10m", + "local_info_announce_period_max_jitter": "1m", + "routing_table_refresh_period": "10m", + "routing_table_refresh_period_max_jitter": "1m", + "announced_peers_channel_capacity": 10 + }, + "peer_resolver": { + "max_parallel_resolve_requests": 100, + "min_ttl_sec": 600, + "update_before_sec": 1200, + "fast_retry_count": 10, + "min_retry_interval": "1s", + "max_retry_interval": "2m", + "stale_retry_interval": "10m" + }, + "overlay": { + "public_overlay_peer_store_period": "3m", + "public_overlay_peer_store_max_jitter": "30s", + "public_overlay_peer_store_max_entries": 20, + "public_overlay_peer_exchange_period": "3m", + "public_overlay_peer_exchange_max_jitter": "30s", + "public_overlay_peer_discovery_period": "3m", + "public_overlay_peer_discovery_max_jitter": "30s", + "exchange_public_entries_batch": 20 + }, + "public_overlay_client": { + "neighbours_update_interval": "2m", + "neighbours_ping_interval": "30s", + "max_neighbours": 5, + "max_ping_tasks": 5, + "default_roundtrip": "300ms" + }, + "storage": { + "root_dir": "/var/node/db", + "rocksdb_enable_metrics": false, + "rocksdb_lru_capacity": "32 GB", + "cells_cache_size": "4.3 GB" + }, + "blockchain_rpc_service": { + "max_key_blocks_list_len": 8, + "serve_persistent_states": true + }, + "blockchain_block_provider": { + "get_next_block_polling_interval": "1s", + "get_block_polling_interval": "1s" + }, + "kafka": { + "brokers": "broker1:9092,broker2:9092,broker3:9092", + "topic": "transactions", + "group_id": "tycho-kafka-producer", + "security_config": { + "kind": "Ssl", + "security_protocol": "Ssl", + "ssl_ca_location": "/var/node/ssl/ca.crt", + "ssl_certificate_location": "/var/node/ssl/client.crt", + "ssl_key_location": "/var/node/ssl/client.key" + } + } +} +``` \ No newline at end of file diff --git a/kafka-producer/src/config.rs b/kafka-producer/src/config.rs index a0a0fd8..80b4f01 100644 --- a/kafka-producer/src/config.rs +++ b/kafka-producer/src/config.rs @@ -1,5 +1,10 @@ use serde::{Deserialize, Serialize}; +#[derive(Debug, Clone, Deserialize, Serialize, Default)] +pub struct UserConfig { + pub kafka: KafkaConsumerConfig, +} + #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(deny_unknown_fields)] pub struct KafkaConsumerConfig { @@ -39,7 +44,7 @@ fn default_session_timeout_ms() -> u32 { #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(deny_unknown_fields)] -#[serde(tag = "security_protocol")] +#[serde(tag = "kind")] pub enum SecurityConfig { #[cfg(feature = "ssl")] Ssl(SslConfig), diff --git a/kafka-producer/src/main.rs b/kafka-producer/src/main.rs index 4e51fcb..409b35a 100644 --- a/kafka-producer/src/main.rs +++ b/kafka-producer/src/main.rs @@ -4,7 +4,7 @@ use anyhow::Context; use clap::Parser; use tikv_jemalloc_ctl::{epoch, stats}; -use crate::config::KafkaConsumerConfig; +use crate::config::UserConfig; use crate::subscriber::KafkaProducer; mod config; @@ -19,7 +19,7 @@ struct ExplorerArgs { node: tycho_light_node::CmdRun, } -type Config = tycho_light_node::NodeConfig; +type Config = tycho_light_node::NodeConfig; #[tokio::main] async fn main() -> anyhow::Result<()> { @@ -37,7 +37,7 @@ async fn main() -> anyhow::Result<()> { let config: Config = tycho_light_node::NodeConfig::from_file(args.node.config.as_ref().context("no config")?)?; - let writer = KafkaProducer::new(config.user_config.clone())?; + let writer = KafkaProducer::new(config.user_config.kafka.clone())?; if let Some(metrics) = &config.metrics { init_metrics(metrics.listen_addr)?;