@@ -136,8 +136,8 @@ impl WritableStore {
136
136
}
137
137
}
138
138
139
- # [ async_trait :: async_trait ]
140
- impl WritableStoreTrait for WritableStore {
139
+ // Methods that mirror `WritableStoreTrait`
140
+ impl WritableStore {
141
141
fn block_ptr ( & self ) -> Result < Option < BlockPtr > , StoreError > {
142
142
self . retry ( "block_ptr" , || self . writable . block_ptr ( self . site . as_ref ( ) ) )
143
143
}
@@ -321,3 +321,115 @@ impl WritableStoreTrait for WritableStore {
321
321
fn same_subgraph ( mods : & Vec < EntityModification > , id : & DeploymentHash ) -> bool {
322
322
mods. iter ( ) . all ( |md| & md. entity_key ( ) . subgraph_id == id)
323
323
}
324
+
325
+ #[ allow( dead_code) ]
326
+ pub struct WritableAgent {
327
+ store : Arc < WritableStore > ,
328
+ }
329
+
330
+ impl WritableAgent {
331
+ pub ( crate ) fn new (
332
+ subgraph_store : SubgraphStore ,
333
+ logger : Logger ,
334
+ site : Arc < Site > ,
335
+ ) -> Result < Self , StoreError > {
336
+ Ok ( Self {
337
+ store : Arc :: new ( WritableStore :: new ( subgraph_store, logger, site) ?) ,
338
+ } )
339
+ }
340
+ }
341
+
342
+ #[ allow( unused_variables) ]
343
+ #[ async_trait:: async_trait]
344
+ impl WritableStoreTrait for WritableAgent {
345
+ fn block_ptr ( & self ) -> Result < Option < BlockPtr > , StoreError > {
346
+ self . store . block_ptr ( )
347
+ }
348
+
349
+ fn block_cursor ( & self ) -> Result < Option < String > , StoreError > {
350
+ self . store . block_cursor ( )
351
+ }
352
+
353
+ fn start_subgraph_deployment ( & self , logger : & Logger ) -> Result < ( ) , StoreError > {
354
+ // TODO: Spin up a background writer thread and establish a channel
355
+ self . store . start_subgraph_deployment ( logger)
356
+ }
357
+
358
+ fn revert_block_operations ( & self , block_ptr_to : BlockPtr ) -> Result < ( ) , StoreError > {
359
+ // TODO: If we haven't written the block yet, revert in memory. If
360
+ // we have, revert in the database
361
+ self . store . revert_block_operations ( block_ptr_to)
362
+ }
363
+
364
+ fn unfail_deterministic_error (
365
+ & self ,
366
+ current_ptr : & BlockPtr ,
367
+ parent_ptr : & BlockPtr ,
368
+ ) -> Result < ( ) , StoreError > {
369
+ self . store
370
+ . unfail_deterministic_error ( current_ptr, parent_ptr)
371
+ }
372
+
373
+ fn unfail_non_deterministic_error ( & self , current_ptr : & BlockPtr ) -> Result < ( ) , StoreError > {
374
+ self . store . unfail_non_deterministic_error ( current_ptr)
375
+ }
376
+
377
+ async fn fail_subgraph ( & self , error : SubgraphError ) -> Result < ( ) , StoreError > {
378
+ self . store . fail_subgraph ( error) . await
379
+ }
380
+
381
+ async fn supports_proof_of_indexing ( & self ) -> Result < bool , StoreError > {
382
+ self . store . supports_proof_of_indexing ( ) . await
383
+ }
384
+
385
+ fn get ( & self , key : & EntityKey ) -> Result < Option < EntityVersion > , StoreError > {
386
+ self . store . get ( key)
387
+ }
388
+
389
+ fn transact_block_operations (
390
+ & self ,
391
+ block_ptr_to : BlockPtr ,
392
+ firehose_cursor : Option < String > ,
393
+ mods : Vec < EntityModification > ,
394
+ stopwatch : StopwatchMetrics ,
395
+ data_sources : Vec < StoredDynamicDataSource > ,
396
+ deterministic_errors : Vec < SubgraphError > ,
397
+ ) -> Result < Vec < ( EntityKey , Vid ) > , StoreError > {
398
+ self . store . transact_block_operations (
399
+ block_ptr_to,
400
+ firehose_cursor,
401
+ mods,
402
+ stopwatch,
403
+ data_sources,
404
+ deterministic_errors,
405
+ )
406
+ }
407
+
408
+ fn get_many (
409
+ & self ,
410
+ ids_for_type : BTreeMap < & EntityType , Vec < & str > > ,
411
+ ) -> Result < BTreeMap < EntityType , Vec < EntityVersion > > , StoreError > {
412
+ self . store . get_many ( ids_for_type)
413
+ }
414
+
415
+ fn deployment_synced ( & self ) -> Result < ( ) , StoreError > {
416
+ self . store . deployment_synced ( )
417
+ }
418
+
419
+ async fn is_deployment_synced ( & self ) -> Result < bool , StoreError > {
420
+ self . store . is_deployment_synced ( ) . await
421
+ }
422
+
423
+ fn unassign_subgraph ( & self ) -> Result < ( ) , StoreError > {
424
+ self . store . unassign_subgraph ( )
425
+ }
426
+
427
+ async fn load_dynamic_data_sources ( & self ) -> Result < Vec < StoredDynamicDataSource > , StoreError > {
428
+ // TODO: Combine in-memory and stored data sources
429
+ self . store . load_dynamic_data_sources ( ) . await
430
+ }
431
+
432
+ fn shard ( & self ) -> & str {
433
+ self . store . shard ( )
434
+ }
435
+ }
0 commit comments