diff options
Diffstat (limited to 'src/table/gc.rs')
-rw-r--r-- | src/table/gc.rs | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/table/gc.rs b/src/table/gc.rs index c03648ef..9b3d60ff 100644 --- a/src/table/gc.rs +++ b/src/table/gc.rs @@ -36,11 +36,10 @@ enum GcRpc { Update(Vec<ByteBuf>), DeleteIfEqualHash(Vec<(ByteBuf, Hash)>), Ok, - Error(String), } -impl Message for GcRpc { - type Response = GcRpc; +impl Rpc for GcRpc { + type Response = Result<GcRpc, Error>; } impl<F, R> TableGc<F, R> @@ -168,7 +167,7 @@ where async fn try_send_and_delete( &self, - nodes: Vec<NodeID>, + nodes: Vec<Uuid>, items: Vec<(ByteBuf, Hash, ByteBuf)>, ) -> Result<(), Error> { let n_items = items.len(); @@ -224,8 +223,15 @@ where .compare_and_swap::<_, _, Vec<u8>>(key, Some(vhash), None)?; Ok(()) } +} - async fn handle_rpc(&self, message: &GcRpc) -> Result<GcRpc, Error> { +#[async_trait] +impl<F, R> EndpointHandler<GcRpc> for TableGc<F, R> +where + F: TableSchema + 'static, + R: TableReplication + 'static, +{ + async fn handle(self: &Arc<Self>, message: &GcRpc, _from: NodeID) -> Result<GcRpc, Error> { match message { GcRpc::Update(items) => { self.data.update_many(items)?; @@ -242,16 +248,3 @@ where } } } - -#[async_trait] -impl<F, R> EndpointHandler<GcRpc> for TableGc<F, R> -where - F: TableSchema + 'static, - R: TableReplication + 'static, -{ - async fn handle(self: &Arc<Self>, message: &GcRpc, _from: NodeID) -> GcRpc { - self.handle_rpc(message) - .await - .unwrap_or_else(|e| GcRpc::Error(format!("{}", e))) - } -} |