Constellation, Spacedust, Slingshot, UFOs: atproto crates and services for microcosm

slingshot: configurable cache sizes #3

closed opened by nekomimi.pet targeting main from nekomimi.pet/microcosm-rs: main

I noticed defaults were hardcoded

./slingshot --jetstream us-east-1 --cache-dir ./foyer \
    --cache-memory-mb 128 \
    --cache-disk-gb 2
Labels

None yet.

Participants 2
AT URI
at://did:plc:ttdrpj45ibqunmfhdsb4zdwq/sh.tangled.repo.pull/3m5zrhmq67x22
+17 -5
Interdiff #0 โ†’ #1
slingshot/src/firehose_cache.rs

This file has not been changed.

+10 -4
slingshot/src/main.rs
··· 31 31 /// disk cache size in GB 32 32 #[arg(long, default_value_t = 1)] 33 33 cache_disk_gb: usize, 34 + /// port for HTTP server (when not using --domain) 35 + #[arg(long, default_value_t = 3000)] 36 + port: u16, 37 + /// port for metrics/prometheus server 38 + #[arg(long, default_value_t = 8765)] 39 + metrics_port: u16, 34 40 /// the domain pointing to this server 35 41 /// 36 42 /// if present: ··· 68 74 69 75 let args = Args::parse(); 70 76 71 - if let Err(e) = install_metrics_server() { 77 + if let Err(e) = install_metrics_server(args.metrics_port) { 72 78 log::error!("failed to install metrics server: {e:?}"); 73 79 } else { 74 - log::info!("metrics listening at http://0.0.0.0:8765"); 80 + log::info!("metrics listening at http://0.0.0.0:{}", args.metrics_port); 75 81 } 76 82 77 83 std::fs::create_dir_all(&args.cache_dir).map_err(|e| { ··· 123 129 args.domain, 124 130 args.acme_contact, 125 131 args.certs, 132 + args.port, 126 133 server_shutdown, 127 134 ) 128 135 .await?; ··· 183 190 Ok(()) 184 191 } 185 192 186 - fn install_metrics_server() -> Result<(), metrics_exporter_prometheus::BuildError> { 193 + fn install_metrics_server(port: u16) -> Result<(), metrics_exporter_prometheus::BuildError> { 187 194 log::info!("installing metrics server..."); 188 195 let host = [0, 0, 0, 0]; 189 - let port = 8765; 190 196 PrometheusBuilder::new() 191 197 .set_quantiles(&[0.5, 0.9, 0.99, 1.0])? 192 198 .set_bucket_duration(std::time::Duration::from_secs(300))?
+7 -1
slingshot/src/server.rs
··· 694 694 domain: Option<String>, 695 695 acme_contact: Option<String>, 696 696 certs: Option<PathBuf>, 697 + port: u16, 697 698 shutdown: CancellationToken, 698 699 ) -> Result<(), ServerError> { 699 700 let repo = Arc::new(repo); ··· 752 753 ) 753 754 .await 754 755 } else { 755 - run(TcpListener::bind("127.0.0.1:3000"), app, shutdown).await 756 + run( 757 + TcpListener::bind(format!("127.0.0.1:{port}")), 758 + app, 759 + shutdown, 760 + ) 761 + .await 756 762 } 757 763 } 758 764

History

4 rounds 4 comments
sign up or login to add to the discussion
1 commit
expand
slingshot: add configurable cache sizes, host, and ports
expand 4 comments

sorry about the messy history, i ordered the git reset soft and amend wrong

thank you!!!

the cache size config is perfect, host and port close: i've started moving to a bind arg and giving clap the SocketAddr type directly so it gets parsed out early + one less thing to pass around.

bind stuff came in through a different pr that i just picked up to get merged, so i'm going to get these cache sizes in by picking this up and extracting that for merging

thanks for getting it started!

closed without merging
1 commit
expand
slingshot: add configurable cache sizes, host, and ports
expand 0 comments
2 commits
expand
slingshot: configurable cache sizes
slingshot: add configurable port and host to slingshot, configurable port to metrics
expand 0 comments
1 commit
expand
slingshot: configurable cache sizes
expand 0 comments