integrate rocksdb to gateway client

This commit is contained in:
ghassmo
2021-05-28 16:48:40 +03:00
parent 8362739618
commit c98febd60f
2 changed files with 9 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ use drk::service::{fetch_slabs_loop, GatewayClient};
use drk::Result;
async fn start(executor: Arc<Executor<'_>>) -> Result<()> {
let mut client = GatewayClient::new("127.0.0.1:3333".parse()?);
let mut client = GatewayClient::new("127.0.0.1:3333".parse()?)?;
client.start().await?;
println!("connected to a server");

View File

@@ -119,15 +119,21 @@ impl GatewayService {
pub struct GatewayClient {
protocol: ReqProtocol,
slabstore: SlabStore
}
impl GatewayClient {
pub fn new(addr: SocketAddr) -> GatewayClient {
pub fn new(addr: SocketAddr) -> Result<GatewayClient> {
let protocol = ReqProtocol::new(addr);
GatewayClient { protocol }
let slabstore = SlabStore::new(Path::new("slabstore.db"))?;
Ok(GatewayClient { protocol ,slabstore})
}
pub async fn start(&mut self) -> Result<()> {
self.protocol.start().await?;
Ok(())
}