1- use crate :: util:: EmptyStoreManager ;
21use anyhow:: { Context , Result } ;
32use spin_core:: { async_trait, wasmtime:: component:: Resource } ;
43use spin_world:: v2:: key_value;
@@ -40,23 +39,22 @@ pub struct KeyValueDispatch {
4039}
4140
4241impl KeyValueDispatch {
43- pub fn new ( ) -> Self {
44- Self :: new_with_capacity ( DEFAULT_STORE_TABLE_CAPACITY )
42+ pub fn new ( allowed_stores : HashSet < String > , manager : Arc < dyn StoreManager > ) -> Self {
43+ Self :: new_with_capacity ( allowed_stores , manager , DEFAULT_STORE_TABLE_CAPACITY )
4544 }
4645
47- pub fn new_with_capacity ( capacity : u32 ) -> Self {
46+ pub fn new_with_capacity (
47+ allowed_stores : HashSet < String > ,
48+ manager : Arc < dyn StoreManager > ,
49+ capacity : u32 ,
50+ ) -> Self {
4851 Self {
49- allowed_stores : HashSet :: new ( ) ,
50- manager : Arc :: new ( EmptyStoreManager ) ,
52+ allowed_stores,
53+ manager,
5154 stores : Table :: new ( capacity) ,
5255 }
5356 }
5457
55- pub fn init ( & mut self , allowed_stores : HashSet < String > , manager : Arc < dyn StoreManager > ) {
56- self . allowed_stores = allowed_stores;
57- self . manager = manager;
58- }
59-
6058 pub fn get_store ( & self , store : Resource < key_value:: Store > ) -> anyhow:: Result < & Arc < dyn Store > > {
6159 self . stores . get ( store. rep ( ) ) . context ( "invalid store" )
6260 }
@@ -66,12 +64,6 @@ impl KeyValueDispatch {
6664 }
6765}
6866
69- impl Default for KeyValueDispatch {
70- fn default ( ) -> Self {
71- Self :: new ( )
72- }
73- }
74-
7567#[ async_trait]
7668impl key_value:: Host for KeyValueDispatch { }
7769
0 commit comments