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

only try to hydrate 100 records

+40 -15
+40 -15
slingshot/src/server.rs
··· 866 866 867 867 let t0 = Instant::now(); 868 868 869 - for link in links { 869 + for (i, link) in links.into_iter().enumerate() { 870 870 match link { 871 871 MatchedRef::AtUri(parts) => { 872 872 let non_canonical_url = parts.to_uri(); ··· 886 886 .query_pairs_mut() 887 887 .append_pair("cid", &cid.as_ref().to_string()); 888 888 } 889 - records.insert( 890 - non_canonical_url.clone(), 891 - Hydration::Pending(ProxyHydrationPending { 892 - reason: "deadline".to_string(), 893 - follow_up: follow_up.to_string(), 894 - }), 895 - ); 889 + 890 + if i >= 100 { 891 + records.insert( 892 + non_canonical_url.clone(), 893 + Hydration::Pending(ProxyHydrationPending { 894 + reason: "limit".to_string(), 895 + follow_up: follow_up.to_string(), 896 + }), 897 + ); 898 + continue; 899 + } else { 900 + records.insert( 901 + non_canonical_url.clone(), 902 + Hydration::Pending(ProxyHydrationPending { 903 + reason: "deadline".to_string(), 904 + follow_up: follow_up.to_string(), 905 + }), 906 + ); 907 + } 908 + 896 909 let tx = tx.clone(); 897 910 let identity = self.identity.clone(); 898 911 let repo = self.repo.clone(); ··· 1006 1019 .query_pairs_mut() 1007 1020 .append_pair("identifier", &identifier); 1008 1021 1009 - identifiers.insert( 1010 - identifier.clone(), 1011 - Hydration::Pending(ProxyHydrationPending { 1012 - reason: "deadline".to_string(), 1013 - follow_up: follow_up.to_string(), 1014 - }), 1015 - ); 1022 + if i >= 100 { 1023 + identifiers.insert( 1024 + identifier.clone(), 1025 + Hydration::Pending(ProxyHydrationPending { 1026 + reason: "limit".to_string(), 1027 + follow_up: follow_up.to_string(), 1028 + }), 1029 + ); 1030 + continue; 1031 + } else { 1032 + identifiers.insert( 1033 + identifier.clone(), 1034 + Hydration::Pending(ProxyHydrationPending { 1035 + reason: "deadline".to_string(), 1036 + follow_up: follow_up.to_string(), 1037 + }), 1038 + ); 1039 + } 1040 + 1016 1041 let tx = tx.clone(); 1017 1042 let identity = self.identity.clone(); 1018 1043 tokio::task::spawn(async move {