@@ -201,28 +201,29 @@ pub trait ControlStateDelegate: ControlStateReadAccess + ControlStateWriteAccess
201201impl < T : ControlStateReadAccess + ControlStateWriteAccess + Send + Sync > ControlStateDelegate for T { }
202202
203203/// Query API of the SpacetimeDB control plane.
204+ #[ async_trait]
204205pub trait ControlStateReadAccess {
205206 // Nodes
206- fn get_node_id ( & self ) -> Option < u64 > ;
207- fn get_node_by_id ( & self , node_id : u64 ) -> anyhow:: Result < Option < Node > > ;
208- fn get_nodes ( & self ) -> anyhow:: Result < Vec < Node > > ;
207+ async fn get_node_id ( & self ) -> Option < u64 > ;
208+ async fn get_node_by_id ( & self , node_id : u64 ) -> anyhow:: Result < Option < Node > > ;
209+ async fn get_nodes ( & self ) -> anyhow:: Result < Vec < Node > > ;
209210
210211 // Databases
211- fn get_database_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Database > > ;
212- fn get_database_by_identity ( & self , database_identity : & Identity ) -> anyhow:: Result < Option < Database > > ;
213- fn get_databases ( & self ) -> anyhow:: Result < Vec < Database > > ;
212+ async fn get_database_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Database > > ;
213+ async fn get_database_by_identity ( & self , database_identity : & Identity ) -> anyhow:: Result < Option < Database > > ;
214+ async fn get_databases ( & self ) -> anyhow:: Result < Vec < Database > > ;
214215
215216 // Replicas
216- fn get_replica_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Replica > > ;
217- fn get_replicas ( & self ) -> anyhow:: Result < Vec < Replica > > ;
218- fn get_leader_replica_by_database ( & self , database_id : u64 ) -> Option < Replica > ;
217+ async fn get_replica_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Replica > > ;
218+ async fn get_replicas ( & self ) -> anyhow:: Result < Vec < Replica > > ;
219+ async fn get_leader_replica_by_database ( & self , database_id : u64 ) -> Option < Replica > ;
219220
220221 // Energy
221- fn get_energy_balance ( & self , identity : & Identity ) -> anyhow:: Result < Option < EnergyBalance > > ;
222+ async fn get_energy_balance ( & self , identity : & Identity ) -> anyhow:: Result < Option < EnergyBalance > > ;
222223
223224 // DNS
224- fn lookup_identity ( & self , domain : & str ) -> anyhow:: Result < Option < Identity > > ;
225- fn reverse_lookup ( & self , database_identity : & Identity ) -> anyhow:: Result < Vec < DomainName > > ;
225+ async fn lookup_identity ( & self , domain : & str ) -> anyhow:: Result < Option < Identity > > ;
226+ async fn reverse_lookup ( & self , database_identity : & Identity ) -> anyhow:: Result < Vec < DomainName > > ;
226227}
227228
228229/// Write operations on the SpacetimeDB control plane.
@@ -281,53 +282,54 @@ pub trait ControlStateWriteAccess: Send + Sync {
281282 ) -> anyhow:: Result < SetDomainsResult > ;
282283}
283284
284- impl < T : ControlStateReadAccess + ?Sized > ControlStateReadAccess for Arc < T > {
285+ #[ async_trait]
286+ impl < T : ControlStateReadAccess + Send + Sync + Sync + ?Sized > ControlStateReadAccess for Arc < T > {
285287 // Nodes
286- fn get_node_id ( & self ) -> Option < u64 > {
287- ( * * self ) . get_node_id ( )
288+ async fn get_node_id ( & self ) -> Option < u64 > {
289+ ( * * self ) . get_node_id ( ) . await
288290 }
289- fn get_node_by_id ( & self , node_id : u64 ) -> anyhow:: Result < Option < Node > > {
290- ( * * self ) . get_node_by_id ( node_id)
291+ async fn get_node_by_id ( & self , node_id : u64 ) -> anyhow:: Result < Option < Node > > {
292+ ( * * self ) . get_node_by_id ( node_id) . await
291293 }
292- fn get_nodes ( & self ) -> anyhow:: Result < Vec < Node > > {
293- ( * * self ) . get_nodes ( )
294+ async fn get_nodes ( & self ) -> anyhow:: Result < Vec < Node > > {
295+ ( * * self ) . get_nodes ( ) . await
294296 }
295297
296298 // Databases
297- fn get_database_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Database > > {
298- ( * * self ) . get_database_by_id ( id)
299+ async fn get_database_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Database > > {
300+ ( * * self ) . get_database_by_id ( id) . await
299301 }
300- fn get_database_by_identity ( & self , identity : & Identity ) -> anyhow:: Result < Option < Database > > {
301- ( * * self ) . get_database_by_identity ( identity)
302+ async fn get_database_by_identity ( & self , identity : & Identity ) -> anyhow:: Result < Option < Database > > {
303+ ( * * self ) . get_database_by_identity ( identity) . await
302304 }
303- fn get_databases ( & self ) -> anyhow:: Result < Vec < Database > > {
304- ( * * self ) . get_databases ( )
305+ async fn get_databases ( & self ) -> anyhow:: Result < Vec < Database > > {
306+ ( * * self ) . get_databases ( ) . await
305307 }
306308
307309 // Replicas
308- fn get_replica_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Replica > > {
309- ( * * self ) . get_replica_by_id ( id)
310+ async fn get_replica_by_id ( & self , id : u64 ) -> anyhow:: Result < Option < Replica > > {
311+ ( * * self ) . get_replica_by_id ( id) . await
310312 }
311- fn get_replicas ( & self ) -> anyhow:: Result < Vec < Replica > > {
312- ( * * self ) . get_replicas ( )
313+ async fn get_replicas ( & self ) -> anyhow:: Result < Vec < Replica > > {
314+ ( * * self ) . get_replicas ( ) . await
313315 }
314316
315317 // Energy
316- fn get_energy_balance ( & self , identity : & Identity ) -> anyhow:: Result < Option < EnergyBalance > > {
317- ( * * self ) . get_energy_balance ( identity)
318+ async fn get_energy_balance ( & self , identity : & Identity ) -> anyhow:: Result < Option < EnergyBalance > > {
319+ ( * * self ) . get_energy_balance ( identity) . await
318320 }
319321
320322 // DNS
321- fn lookup_identity ( & self , domain : & str ) -> anyhow:: Result < Option < Identity > > {
322- ( * * self ) . lookup_identity ( domain)
323+ async fn lookup_identity ( & self , domain : & str ) -> anyhow:: Result < Option < Identity > > {
324+ ( * * self ) . lookup_identity ( domain) . await
323325 }
324326
325- fn reverse_lookup ( & self , database_identity : & Identity ) -> anyhow:: Result < Vec < DomainName > > {
326- ( * * self ) . reverse_lookup ( database_identity)
327+ async fn reverse_lookup ( & self , database_identity : & Identity ) -> anyhow:: Result < Vec < DomainName > > {
328+ ( * * self ) . reverse_lookup ( database_identity) . await
327329 }
328330
329- fn get_leader_replica_by_database ( & self , database_id : u64 ) -> Option < Replica > {
330- ( * * self ) . get_leader_replica_by_database ( database_id)
331+ async fn get_leader_replica_by_database ( & self , database_id : u64 ) -> Option < Replica > {
332+ ( * * self ) . get_leader_replica_by_database ( database_id) . await
331333 }
332334}
333335
0 commit comments