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

Configure Feed

Select the types of activity you want to include in your feed.

tweaks for new version of foyer

authored by

phil and committed by tangled.org bd5a9b12 ec71cccd

+23 -6
+8
slingshot/readme.md
··· 5 5 ```bash 6 6 RUST_LOG=info,slingshot=trace ulimit -n 4096 && RUST_LOG=info cargo run -- --jetstream us-east-1 --cache-dir ./foyer 7 7 ``` 8 + 9 + the identity cache uses a lot of files so you probably need to bump ulimit 10 + 11 + on macos: 12 + 13 + ```bash 14 + ulimit -n 4096 15 + ```
+6 -2
slingshot/src/firehose_cache.rs
··· 1 1 use crate::CachedRecord; 2 - use foyer::{BlockEngineConfig, DeviceBuilder, FileDeviceBuilder, HybridCache, HybridCacheBuilder}; 2 + use foyer::{ 3 + BlockEngineConfig, DeviceBuilder, FsDeviceBuilder, HybridCache, HybridCacheBuilder, 4 + PsyncIoEngineConfig, 5 + }; 3 6 use std::path::Path; 4 7 5 8 pub async fn firehose_cache( ··· 7 10 memory_mb: usize, 8 11 disk_gb: usize, 9 12 ) -> Result<HybridCache<String, CachedRecord>, String> { 10 - let device = FileDeviceBuilder::new(cache_dir) 13 + let device = FsDeviceBuilder::new(cache_dir) 11 14 .with_capacity(disk_gb * 2_usize.pow(30)) 12 15 .build() 13 16 .map_err(|e| format!("foyer device setup error: {e}"))?; ··· 21 24 std::mem::size_of_val(k.as_str()) + v.weight() 22 25 }) 23 26 .storage() 27 + .with_io_engine_config(PsyncIoEngineConfig::default()) 24 28 .with_engine_config(engine) 25 29 .build() 26 30 .await
+6 -2
slingshot/src/identity.rs
··· 26 26 handle::{AtprotoHandleResolver, AtprotoHandleResolverConfig, DnsTxtResolver}, 27 27 }; 28 28 use atrium_oauth::DefaultHttpClient; // it's probably not worth bringing all of atrium_oauth for this but 29 - use foyer::{BlockEngineConfig, DeviceBuilder, FileDeviceBuilder, HybridCache, HybridCacheBuilder}; 29 + use foyer::{ 30 + BlockEngineConfig, DeviceBuilder, FsDeviceBuilder, HybridCache, HybridCacheBuilder, 31 + PsyncIoEngineConfig, 32 + }; 30 33 use serde::{Deserialize, Serialize}; 31 34 use time::UtcDateTime; 32 35 ··· 202 205 http_client: http_client.clone(), 203 206 }); 204 207 205 - let device = FileDeviceBuilder::new(cache_dir) 208 + let device = FsDeviceBuilder::new(cache_dir) 206 209 .with_capacity(disk_gb * 2_usize.pow(30)) 207 210 .build()?; 208 211 let engine = BlockEngineConfig::new(device).with_block_size(2_usize.pow(20)); // note: this does limit the max cached item size ··· 212 215 .memory(memory_mb * 2_usize.pow(20)) 213 216 .with_weighter(|k: &IdentityKey, v: &IdentityVal| k.weight() + v.weight()) 214 217 .storage() 218 + .with_io_engine_config(PsyncIoEngineConfig::default()) 215 219 .with_engine_config(engine) 216 220 .build() 217 221 .await?;
+2 -1
slingshot/src/main.rs
··· 4 4 use slingshot::{ 5 5 Identity, Repo, consume, error::MainTaskError, firehose_cache, healthcheck, serve, 6 6 }; 7 + use std::net::SocketAddr; 7 8 use std::path::PathBuf; 8 9 9 10 use clap::Parser; ··· 30 31 /// cannot be used with acme -- if you need ipv6 see --acme-ipv6 31 32 #[arg(long, env = "SLINGSHOT_BIND")] 32 33 #[clap(default_value = "0.0.0.0:8080")] 33 - bind: std::net::SocketAddr, 34 + bind: SocketAddr, 34 35 /// memory cache size in megabytes for records 35 36 #[arg(long, env = "SLINGSHOT_RECORD_CACHE_MEMORY_MB")] 36 37 #[clap(default_value_t = 64)]
+1 -1
slingshot/src/server.rs
··· 713 713 .server(if let Some(ref h) = acme_domain { 714 714 format!("https://{h}") 715 715 } else { 716 - "http://localhost:3000".to_string() 716 + format!("http://{bind}") // yeah should probably fix this for reverse-proxy scenarios but it's ok for dev for now 717 717 }) 718 718 .url_prefix("/xrpc") 719 719 .contact(