@@ -7,7 +7,6 @@ use ufos::file_consumer;
77use ufos:: server;
88use ufos:: storage:: { StorageWhatever , StoreBackground , StoreReader , StoreWriter } ;
99use ufos:: storage_fjall:: FjallStorage ;
10- use ufos:: storage_mem:: MemStorage ;
1110use ufos:: store_types:: SketchSecretPrefix ;
1211use ufos:: { nice_duration, ConsumerInfo } ;
1312
@@ -19,7 +18,7 @@ use tikv_jemallocator::Jemalloc;
1918static GLOBAL : Jemalloc = Jemalloc ;
2019
2120/// Aggregate links in the at-mosphere
22- #[ derive( Parser , Debug ) ]
21+ #[ derive( Parser , Debug , Clone ) ]
2322#[ command( version, about, long_about = None ) ]
2423struct Args {
2524 /// Jetstream server to connect to (exclusive with --fixture). Provide either a wss:// URL, or a shorhand value:
@@ -47,9 +46,6 @@ struct Args {
4746 /// todo: restore this
4847 #[ arg( long, action) ]
4948 pause_rw : bool ,
50- /// DEBUG: use an in-memory store instead of fjall
51- #[ arg( long, action) ]
52- in_mem : bool ,
5349 /// reset the rollup cursor, scrape through missed things in the past (backfill)
5450 #[ arg( long, action) ]
5551 reroll : bool ,
@@ -64,56 +60,18 @@ async fn main() -> anyhow::Result<()> {
6460
6561 let args = Args :: parse ( ) ;
6662 let jetstream = args. jetstream . clone ( ) ;
67- if args. in_mem {
68- let ( read_store, write_store, cursor, sketch_secret) = MemStorage :: init (
69- args. data ,
70- jetstream,
71- args. jetstream_force ,
72- Default :: default ( ) ,
73- ) ?;
74- go (
75- args. jetstream ,
76- args. jetstream_fixture ,
77- args. pause_writer ,
78- args. backfill ,
79- args. reroll ,
80- read_store,
81- write_store,
82- cursor,
83- sketch_secret,
84- )
85- . await ?;
86- } else {
87- let ( read_store, write_store, cursor, sketch_secret) = FjallStorage :: init (
88- args. data ,
89- jetstream,
90- args. jetstream_force ,
91- Default :: default ( ) ,
92- ) ?;
93- go (
94- args. jetstream ,
95- args. jetstream_fixture ,
96- args. pause_writer ,
97- args. backfill ,
98- args. reroll ,
99- read_store,
100- write_store,
101- cursor,
102- sketch_secret,
103- )
104- . await ?;
105- }
106-
63+ let ( read_store, write_store, cursor, sketch_secret) = FjallStorage :: init (
64+ args. data . clone ( ) ,
65+ jetstream,
66+ args. jetstream_force ,
67+ Default :: default ( ) ,
68+ ) ?;
69+ go ( args, read_store, write_store, cursor, sketch_secret) . await ?;
10770 Ok ( ( ) )
10871}
10972
110- #[ allow( clippy:: too_many_arguments) ]
11173async fn go < B : StoreBackground > (
112- jetstream : String ,
113- jetstream_fixture : bool ,
114- pause_writer : bool ,
115- backfill : bool ,
116- reroll : bool ,
74+ args : Args ,
11775 read_store : impl StoreReader + ' static + Clone ,
11876 mut write_store : impl StoreWriter < B > + ' static ,
11977 cursor : Option < Cursor > ,
@@ -122,24 +80,26 @@ async fn go<B: StoreBackground>(
12280 println ! ( "starting server with storage..." ) ;
12381 let serving = server:: serve ( read_store. clone ( ) ) ;
12482
125- if pause_writer {
83+ if args . pause_writer {
12684 log:: info!( "not starting jetstream or the write loop." ) ;
12785 serving. await . map_err ( |e| anyhow:: anyhow!( e) ) ?;
12886 return Ok ( ( ) ) ;
12987 }
13088
131- let batches = if jetstream_fixture {
132- log:: info!( "starting with jestream file fixture: {jetstream :?}" ) ;
133- file_consumer:: consume ( jetstream. into ( ) , sketch_secret, cursor) . await ?
89+ let batches = if args . jetstream_fixture {
90+ log:: info!( "starting with jestream file fixture: {:?}" , args . jetstream ) ;
91+ file_consumer:: consume ( args . jetstream . into ( ) , sketch_secret, cursor) . await ?
13492 } else {
13593 log:: info!(
13694 "starting consumer with cursor: {cursor:?} from {:?} ago" ,
13795 cursor. map( |c| c. elapsed( ) )
13896 ) ;
139- consumer:: consume ( & jetstream, cursor, false , sketch_secret) . await ?
97+ consumer:: consume ( & args . jetstream , cursor, false , sketch_secret) . await ?
14098 } ;
14199
142- let rolling = write_store. background_tasks ( reroll) ?. run ( backfill) ;
100+ let rolling = write_store
101+ . background_tasks ( args. reroll ) ?
102+ . run ( args. backfill ) ;
143103 let storing = write_store. receive_batches ( batches) ;
144104
145105 let stating = do_update_stuff ( read_store) ;
0 commit comments