Skip to content

Commit

Permalink
docs: add example config
Browse files Browse the repository at this point in the history
  • Loading branch information
0xdeafbeef committed Nov 7, 2024
1 parent 0bcff05 commit 3159d9c
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 4 deletions.
89 changes: 89 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
```
7 changes: 6 additions & 1 deletion kafka-producer/src/config.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions kafka-producer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +19,7 @@ struct ExplorerArgs {
node: tycho_light_node::CmdRun,
}

type Config = tycho_light_node::NodeConfig<KafkaConsumerConfig>;
type Config = tycho_light_node::NodeConfig<UserConfig>;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
Expand All @@ -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)?;
Expand Down

0 comments on commit 3159d9c

Please sign in to comment.