|
@@ -21,7 +21,7 @@ enum GatewayCommand {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pub struct GatewayService {
|
|
pub struct GatewayService {
|
|
|
- slabstore: SlabStore,
|
|
|
|
|
|
|
+ slabstore: Arc<SlabStore>,
|
|
|
addr: SocketAddr,
|
|
addr: SocketAddr,
|
|
|
publisher: Mutex<Publisher>,
|
|
publisher: Mutex<Publisher>,
|
|
|
}
|
|
}
|
|
@@ -76,7 +76,8 @@ impl GatewayService {
|
|
|
let reply = Reply::from(&request, 0, vec![]);
|
|
let reply = Reply::from(&request, 0, vec![]);
|
|
|
send_queue.send(reply).await?;
|
|
send_queue.send(reply).await?;
|
|
|
|
|
|
|
|
- // publish to all subscribes self.publisher.lock().await.publish(slab).await?;
|
|
|
|
|
|
|
+ // publish to all subscribes
|
|
|
|
|
+ self.publisher.lock().await.publish(slab).await?;
|
|
|
|
|
|
|
|
info!("received putslab msg");
|
|
info!("received putslab msg");
|
|
|
}
|
|
}
|
|
@@ -120,14 +121,14 @@ impl GatewayService {
|
|
|
|
|
|
|
|
pub struct GatewayClient {
|
|
pub struct GatewayClient {
|
|
|
protocol: ReqProtocol,
|
|
protocol: ReqProtocol,
|
|
|
- slabstore: SlabStore,
|
|
|
|
|
|
|
+ pub slabstore: Arc<SlabStore>,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
impl GatewayClient {
|
|
impl GatewayClient {
|
|
|
- pub fn new(addr: SocketAddr) -> Result<GatewayClient> {
|
|
|
|
|
|
|
+ pub fn new(addr: SocketAddr, path: &str) -> Result<Self> {
|
|
|
let protocol = ReqProtocol::new(addr);
|
|
let protocol = ReqProtocol::new(addr);
|
|
|
|
|
|
|
|
- let slabstore = SlabStore::new(Path::new("slabstore_client.db"))?;
|
|
|
|
|
|
|
+ let slabstore = SlabStore::new(Path::new(path))?;
|
|
|
|
|
|
|
|
Ok(GatewayClient {
|
|
Ok(GatewayClient {
|
|
|
protocol,
|
|
protocol,
|
|
@@ -177,7 +178,6 @@ impl GatewayClient {
|
|
|
|
|
|
|
|
Ok(())
|
|
Ok(())
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
pub async fn get_last_index(&mut self) -> Result<u64> {
|
|
pub async fn get_last_index(&mut self) -> Result<u64> {
|
|
|
let rep = self
|
|
let rep = self
|
|
|
.protocol
|
|
.protocol
|
|
@@ -185,6 +185,11 @@ impl GatewayClient {
|
|
|
.await?;
|
|
.await?;
|
|
|
Ok(deserialize(&rep)?)
|
|
Ok(deserialize(&rep)?)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ pub fn get_slabstore(&self) -> Arc<SlabStore> {
|
|
|
|
|
+ self.slabstore.clone()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
pub async fn fetch_slabs_loop(
|
|
pub async fn fetch_slabs_loop(
|
|
@@ -201,3 +206,4 @@ pub async fn fetch_slabs_loop(
|
|
|
slabs.lock().await.push(slab);
|
|
slabs.lock().await.push(slab);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|