diff --git a/src/app.rs b/src/app.rs index edc8403..4e23395 100644 --- a/src/app.rs +++ b/src/app.rs @@ -19,16 +19,16 @@ use std::sync::Arc; use openraft::Config; -use crate::ExampleNodeId; -use crate::ExampleRaft; -use crate::ExampleStore; +use crate::DcacheNodeId; +use crate::DcacheRaft; +use crate::DcacheStore; // Representation of an application state. This struct can be shared around to share // instances of raft, store and more. -pub struct ExampleApp { - pub id: ExampleNodeId, +pub struct DcacheApp { + pub id: DcacheNodeId, pub addr: String, - pub raft: ExampleRaft, - pub store: Arc, + pub raft: DcacheRaft, + pub store: Arc, pub config: Arc, } diff --git a/src/bin/main.rs b/src/bin/main.rs index 78d9374..3c9e2a0 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -16,14 +16,14 @@ * along with this program. If not, see . */ use clap::Parser; -use dcache::network::raft_network_impl::ExampleNetwork; +use dcache::network::raft_network_impl::DcacheNetwork; use dcache::start_example_raft_node; -use dcache::store::ExampleStore; -use dcache::ExampleTypeConfig; +use dcache::store::DcacheStore; +use dcache::DcacheTypeConfig; use openraft::Raft; use tracing_subscriber::EnvFilter; -pub type ExampleRaft = Raft; +pub type DcacheRaft = Raft; #[derive(Parser, Clone, Debug)] #[clap(author, version, about, long_about = None)] diff --git a/src/client.rs b/src/client.rs index b3c3749..a28d130 100644 --- a/src/client.rs +++ b/src/client.rs @@ -34,24 +34,24 @@ use serde::Serialize; use tokio::time::timeout; use crate::typ; -use crate::ExampleNodeId; -use crate::ExampleRequest; +use crate::DcacheNodeId; +use crate::DcacheRequest; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Empty {} -pub struct ExampleClient { +pub struct DcacheClient { /// The leader node to send request to. /// /// All traffic should be sent to the leader in a cluster. - pub leader: Arc>, + pub leader: Arc>, pub inner: Client, } -impl ExampleClient { +impl DcacheClient { /// Create a client with a leader node id and a node manager to get node address by node id. - pub fn new(leader_id: ExampleNodeId, leader_addr: String) -> Self { + pub fn new(leader_id: DcacheNodeId, leader_addr: String) -> Self { Self { leader: Arc::new(Mutex::new((leader_id, leader_addr))), inner: reqwest::Client::new(), @@ -68,7 +68,7 @@ impl ExampleClient { /// The result of applying the request will be returned. pub async fn write( &self, - req: &ExampleRequest, + req: &DcacheRequest, ) -> Result> { self.send_rpc_to_leader("write", Some(req)).await } @@ -105,10 +105,10 @@ impl ExampleClient { /// Add a node as learner. /// - /// The node to add has to exist, i.e., being added with `write(ExampleRequest::AddNode{})` + /// The node to add has to exist, i.e., being added with `write(DcacheRequest::AddNode{})` pub async fn add_learner( &self, - req: (ExampleNodeId, String), + req: (DcacheNodeId, String), ) -> Result> { self.send_rpc_to_leader("add-learner", Some(&req)).await } @@ -119,7 +119,7 @@ impl ExampleClient { /// or an error [`LearnerNotFound`] will be returned. pub async fn change_membership( &self, - req: &BTreeSet, + req: &BTreeSet, ) -> Result> { self.send_rpc_to_leader("change-membership", Some(req)) .await @@ -130,7 +130,7 @@ impl ExampleClient { /// Metrics contains various information about the cluster, such as current leader, /// membership config, replication status etc. /// See [`RaftMetrics`]. - pub async fn metrics(&self) -> Result, typ::RPCError> { + pub async fn metrics(&self) -> Result, typ::RPCError> { self.do_send_rpc_to_leader("metrics", None::<&()>).await } diff --git a/src/lib.rs b/src/lib.rs index af5e25e..46e1c3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,50 +28,50 @@ use openraft::BasicNode; use openraft::Config; use openraft::Raft; -use crate::app::ExampleApp; +use crate::app::DcacheApp; use crate::network::api; use crate::network::management; use crate::network::raft; -use crate::network::raft_network_impl::ExampleNetwork; -use crate::store::ExampleRequest; -use crate::store::ExampleResponse; -use crate::store::ExampleStore; +use crate::network::raft_network_impl::DcacheNetwork; +use crate::store::DcacheRequest; +use crate::store::DcacheResponse; +use crate::store::DcacheStore; pub mod app; pub mod client; pub mod network; pub mod store; -pub type ExampleNodeId = u64; +pub type DcacheNodeId = u64; openraft::declare_raft_types!( /// Declare the type configuration for example K/V store. - pub ExampleTypeConfig: D = ExampleRequest, R = ExampleResponse, NodeId = ExampleNodeId, Node = BasicNode + pub DcacheTypeConfig: D = DcacheRequest, R = DcacheResponse, NodeId = DcacheNodeId, Node = BasicNode ); -pub type ExampleRaft = Raft>; +pub type DcacheRaft = Raft>; pub mod typ { use openraft::BasicNode; - use crate::ExampleNodeId; - use crate::ExampleTypeConfig; + use crate::DcacheNodeId; + use crate::DcacheTypeConfig; pub type RaftError = - openraft::error::RaftError; + openraft::error::RaftError; pub type RPCError = - openraft::error::RPCError>; + openraft::error::RPCError>; - pub type ClientWriteError = openraft::error::ClientWriteError; - pub type CheckIsLeaderError = openraft::error::CheckIsLeaderError; - pub type ForwardToLeader = openraft::error::ForwardToLeader; - pub type InitializeError = openraft::error::InitializeError; + pub type ClientWriteError = openraft::error::ClientWriteError; + pub type CheckIsLeaderError = openraft::error::CheckIsLeaderError; + pub type ForwardToLeader = openraft::error::ForwardToLeader; + pub type InitializeError = openraft::error::InitializeError; - pub type ClientWriteResponse = openraft::raft::ClientWriteResponse; + pub type ClientWriteResponse = openraft::raft::ClientWriteResponse; } pub async fn start_example_raft_node( - node_id: ExampleNodeId, + node_id: DcacheNodeId, http_addr: String, ) -> std::io::Result<()> { // Create a configuration for the raft instance. @@ -89,11 +89,11 @@ pub async fn start_example_raft_node( let config = Arc::new(config.validate().unwrap()); // Create a instance of where the Raft data will be stored. - let store = Arc::new(ExampleStore::new(salt)); + let store = Arc::new(DcacheStore::new(salt)); // Create the network layer that will connect and communicate the raft instances and // will be used in conjunction with the store created above. - let network = ExampleNetwork {}; + let network = DcacheNetwork {}; // Create a local raft instance. let raft = Raft::new(node_id, config.clone(), network, store.clone()) @@ -102,7 +102,7 @@ pub async fn start_example_raft_node( // Create an application that will store all the instances created above, this will // be later used on the actix-web services. - let app = Data::new(ExampleApp { + let app = Data::new(DcacheApp { id: node_id, addr: http_addr.clone(), raft, diff --git a/src/network/api.rs b/src/network/api.rs index ce7cdf2..b2e9797 100644 --- a/src/network/api.rs +++ b/src/network/api.rs @@ -25,9 +25,9 @@ use openraft::error::RaftError; use openraft::BasicNode; use web::Json; -use crate::app::ExampleApp; -use crate::store::ExampleRequest; -use crate::ExampleNodeId; +use crate::app::DcacheApp; +use crate::store::DcacheRequest; +use crate::DcacheNodeId; /** * Application API @@ -40,8 +40,8 @@ use crate::ExampleNodeId; */ #[post("/write")] pub async fn write( - app: Data, - req: Json, + app: Data, + req: Json, ) -> actix_web::Result { let response = app.raft.client_write(req.0).await; Ok(Json(response)) @@ -51,7 +51,7 @@ pub async fn write( // RenameCaptcha(RenameCaptcha), // RemoveCaptcha(RemoveCaptcha), //#[post("/post")] -//pub async fn read(app: Data, req: Json) -> actix_web::Result { +//pub async fn read(app: Data, req: Json) -> actix_web::Result { // let state_machine = app.store.state_machine.read().await; // let key = req.0; // let value = state_machine.data.get(&key).cloned(); @@ -61,7 +61,7 @@ pub async fn write( //} // //#[post("/visitor/add")] -//pub async fn add_visitor(app: Data, req: Json) -> actix_web::Result { +//pub async fn add_visitor(app: Data, req: Json) -> actix_web::Result { // let state_machine = app.store.state_machine.read().await; // let key = req.0; // let value = state_machine.data.get(&key).cloned(); diff --git a/src/network/management.rs b/src/network/management.rs index 1af82df..cd77ac8 100644 --- a/src/network/management.rs +++ b/src/network/management.rs @@ -28,8 +28,8 @@ use openraft::BasicNode; use openraft::RaftMetrics; use web::Json; -use crate::app::ExampleApp; -use crate::ExampleNodeId; +use crate::app::DcacheApp; +use crate::DcacheNodeId; // --- Cluster management @@ -40,8 +40,8 @@ use crate::ExampleNodeId; /// (by calling `change-membership`) #[post("/add-learner")] pub async fn add_learner( - app: Data, - req: Json<(ExampleNodeId, String)>, + app: Data, + req: Json<(DcacheNodeId, String)>, ) -> actix_web::Result { let node_id = req.0 .0; let node = BasicNode { @@ -54,8 +54,8 @@ pub async fn add_learner( /// Changes specified learners to members, or remove members. #[post("/change-membership")] pub async fn change_membership( - app: Data, - req: Json>, + app: Data, + req: Json>, ) -> actix_web::Result { let res = app.raft.change_membership(req.0, false).await; Ok(Json(res)) @@ -63,7 +63,7 @@ pub async fn change_membership( /// Initialize a single-node cluster. #[post("/init")] -pub async fn init(app: Data) -> actix_web::Result { +pub async fn init(app: Data) -> actix_web::Result { let mut nodes = BTreeMap::new(); nodes.insert( app.id, @@ -77,9 +77,9 @@ pub async fn init(app: Data) -> actix_web::Result { /// Get the latest metrics of the cluster #[get("/metrics")] -pub async fn metrics(app: Data) -> actix_web::Result { +pub async fn metrics(app: Data) -> actix_web::Result { let metrics = app.raft.metrics().borrow().clone(); - let res: Result, Infallible> = Ok(metrics); + let res: Result, Infallible> = Ok(metrics); Ok(Json(res)) } diff --git a/src/network/raft.rs b/src/network/raft.rs index aa2a384..2ac62d6 100644 --- a/src/network/raft.rs +++ b/src/network/raft.rs @@ -24,16 +24,16 @@ use openraft::raft::InstallSnapshotRequest; use openraft::raft::VoteRequest; use web::Json; -use crate::app::ExampleApp; -use crate::ExampleNodeId; -use crate::ExampleTypeConfig; +use crate::app::DcacheApp; +use crate::DcacheNodeId; +use crate::DcacheTypeConfig; // --- Raft communication #[post("/raft-vote")] pub async fn vote( - app: Data, - req: Json>, + app: Data, + req: Json>, ) -> actix_web::Result { let res = app.raft.vote(req.0).await; Ok(Json(res)) @@ -41,8 +41,8 @@ pub async fn vote( #[post("/raft-append")] pub async fn append( - app: Data, - req: Json>, + app: Data, + req: Json>, ) -> actix_web::Result { let res = app.raft.append_entries(req.0).await; Ok(Json(res)) @@ -50,8 +50,8 @@ pub async fn append( #[post("/raft-snapshot")] pub async fn snapshot( - app: Data, - req: Json>, + app: Data, + req: Json>, ) -> actix_web::Result { let res = app.raft.install_snapshot(req.0).await; Ok(Json(res)) diff --git a/src/network/raft_network_impl.rs b/src/network/raft_network_impl.rs index 4a5a9bf..3482f6f 100644 --- a/src/network/raft_network_impl.rs +++ b/src/network/raft_network_impl.rs @@ -33,19 +33,19 @@ use openraft::RaftNetworkFactory; use serde::de::DeserializeOwned; use serde::Serialize; -use crate::ExampleNodeId; -use crate::ExampleTypeConfig; +use crate::DcacheNodeId; +use crate::DcacheTypeConfig; -pub struct ExampleNetwork {} +pub struct DcacheNetwork {} -impl ExampleNetwork { +impl DcacheNetwork { pub async fn send_rpc( &self, - target: ExampleNodeId, + target: DcacheNodeId, target_node: &BasicNode, uri: &str, req: Req, - ) -> Result> + ) -> Result> where Req: Serialize, Err: std::error::Error + DeserializeOwned, @@ -79,35 +79,35 @@ impl ExampleNetwork { } } -// NOTE: This could be implemented also on `Arc`, but since it's empty, implemented +// NOTE: This could be implemented also on `Arc`, but since it's empty, implemented // directly. #[async_trait] -impl RaftNetworkFactory for ExampleNetwork { - type Network = ExampleNetworkConnection; +impl RaftNetworkFactory for DcacheNetwork { + type Network = DcacheNetworkConnection; - async fn new_client(&mut self, target: ExampleNodeId, node: &BasicNode) -> Self::Network { - ExampleNetworkConnection { - owner: ExampleNetwork {}, + async fn new_client(&mut self, target: DcacheNodeId, node: &BasicNode) -> Self::Network { + DcacheNetworkConnection { + owner: DcacheNetwork {}, target, target_node: node.clone(), } } } -pub struct ExampleNetworkConnection { - owner: ExampleNetwork, - target: ExampleNodeId, +pub struct DcacheNetworkConnection { + owner: DcacheNetwork, + target: DcacheNodeId, target_node: BasicNode, } #[async_trait] -impl RaftNetwork for ExampleNetworkConnection { +impl RaftNetwork for DcacheNetworkConnection { async fn send_append_entries( &mut self, - req: AppendEntriesRequest, + req: AppendEntriesRequest, ) -> Result< - AppendEntriesResponse, - RPCError>, + AppendEntriesResponse, + RPCError>, > { self.owner .send_rpc(self.target, &self.target_node, "raft-append", req) @@ -116,10 +116,10 @@ impl RaftNetwork for ExampleNetworkConnection { async fn send_install_snapshot( &mut self, - req: InstallSnapshotRequest, + req: InstallSnapshotRequest, ) -> Result< - InstallSnapshotResponse, - RPCError>, + InstallSnapshotResponse, + RPCError>, > { self.owner .send_rpc(self.target, &self.target_node, "raft-snapshot", req) @@ -128,10 +128,10 @@ impl RaftNetwork for ExampleNetworkConnection { async fn send_vote( &mut self, - req: VoteRequest, + req: VoteRequest, ) -> Result< - VoteResponse, - RPCError>, + VoteResponse, + RPCError>, > { self.owner .send_rpc(self.target, &self.target_node, "raft-vote", req) diff --git a/src/store/mod.rs b/src/store/mod.rs index 2f7aa1e..de048c9 100644 --- a/src/store/mod.rs +++ b/src/store/mod.rs @@ -49,8 +49,8 @@ use sqlx::Statement; use tokio::sync::RwLock; use url::quirks::set_pathname; -use crate::ExampleNodeId; -use crate::ExampleTypeConfig; +use crate::DcacheNodeId; +use crate::DcacheTypeConfig; use actix::prelude::*; use libmcaptcha::master::messages::{ @@ -68,7 +68,7 @@ pub mod system; * You will want to add any request that can write data in all nodes here. */ #[derive(Serialize, Deserialize, Debug, Clone)] -pub enum ExampleRequest { +pub enum DcacheRequest { //Set { key: String, value: String }, AddVisitor(AddVisitor), AddCaptcha(AddCaptcha), @@ -79,13 +79,13 @@ pub enum ExampleRequest { /** * Here you will defined what type of answer you expect from reading the data of a node. * In this example it will return a optional value from a given key in - * the `ExampleRequest.Set`. + * the `DcacheRequest.Set`. * * TODO: Should we explain how to create multiple `AppDataResponse`? * */ #[derive(Serialize, Deserialize, Debug, Clone)] -pub enum ExampleResponse { +pub enum DcacheResponse { AddVisitorResult(Option), Empty, // AddCaptchaResult, All returns () @@ -94,8 +94,8 @@ pub enum ExampleResponse { } #[derive(Debug)] -pub struct ExampleSnapshot { - pub meta: SnapshotMeta, +pub struct DcacheSnapshot { + pub meta: SnapshotMeta, /// The data of the state machine at the time of this snapshot. pub data: Vec, @@ -107,10 +107,10 @@ pub struct ExampleSnapshot { * a implementation to be serialized. Note that for this test we set both the key and * value as String, but you could set any type of value that has the serialization impl. */ -pub struct ExampleStateMachine { - pub last_applied_log: Option>, +pub struct DcacheStateMachine { + pub last_applied_log: Option>, - pub last_membership: StoredMembership, + pub last_membership: StoredMembership, /// Application data. pub data: Arc>, @@ -118,16 +118,16 @@ pub struct ExampleStateMachine { #[derive(Serialize, Deserialize, Clone)] struct PersistableStateMachine { - last_applied_log: Option>, + last_applied_log: Option>, - last_membership: StoredMembership, + last_membership: StoredMembership, /// Application data. data: HashMap, } impl PersistableStateMachine { - async fn from_statemachine(m: &ExampleStateMachine) -> Self { + async fn from_statemachine(m: &DcacheStateMachine) -> Self { let internal_data = m .data .master @@ -147,14 +147,14 @@ impl PersistableStateMachine { async fn to_statemachine( self, data: Arc>, - ) -> ExampleStateMachine { + ) -> DcacheStateMachine { data.master .send(SetInternalData { mcaptcha: self.data, }) .await .unwrap(); - ExampleStateMachine { + DcacheStateMachine { last_applied_log: self.last_applied_log, last_membership: self.last_membership, data, @@ -162,26 +162,26 @@ impl PersistableStateMachine { } } -pub struct ExampleStore { - last_purged_log_id: RwLock>>, +pub struct DcacheStore { + last_purged_log_id: RwLock>>, /// The Raft log. - log: RwLock>>, + log: RwLock>>, /// The Raft state machine. - pub state_machine: RwLock, + pub state_machine: RwLock, /// The current granted vote. - vote: RwLock>>, + vote: RwLock>>, snapshot_idx: Arc>, - current_snapshot: RwLock>, + current_snapshot: RwLock>, } -impl ExampleStore { +impl DcacheStore { pub fn new(salt: String) -> Self { - let state_machine = RwLock::new(ExampleStateMachine { + let state_machine = RwLock::new(DcacheStateMachine { last_applied_log: Default::default(), last_membership: Default::default(), data: system::init_system(salt), @@ -199,10 +199,10 @@ impl ExampleStore { } #[async_trait] -impl RaftLogReader for Arc { +impl RaftLogReader for Arc { async fn get_log_state( &mut self, - ) -> Result, StorageError> { + ) -> Result, StorageError> { let log = self.log.read().await; let last = log.iter().rev().next().map(|(_, ent)| ent.log_id); @@ -222,7 +222,7 @@ impl RaftLogReader for Arc { async fn try_get_log_entries + Clone + Debug + Send + Sync>( &mut self, range: RB, - ) -> Result>, StorageError> { + ) -> Result>, StorageError> { let log = self.log.read().await; let response = log .range(range.clone()) @@ -233,11 +233,11 @@ impl RaftLogReader for Arc { } #[async_trait] -impl RaftSnapshotBuilder>> for Arc { +impl RaftSnapshotBuilder>> for Arc { #[tracing::instrument(level = "trace", skip(self))] async fn build_snapshot( &mut self, - ) -> Result>>, StorageError> + ) -> Result>>, StorageError> { let data; let last_applied_log; @@ -279,7 +279,7 @@ impl RaftSnapshotBuilder>> for Arc>> for Arc for Arc { +impl RaftStorage for Arc { type SnapshotData = Cursor>; type LogReader = Self; type SnapshotBuilder = Self; @@ -305,8 +305,8 @@ impl RaftStorage for Arc { #[tracing::instrument(level = "trace", skip(self))] async fn save_vote( &mut self, - vote: &Vote, - ) -> Result<(), StorageError> { + vote: &Vote, + ) -> Result<(), StorageError> { let mut v = self.vote.write().await; *v = Some(*vote); Ok(()) @@ -314,15 +314,15 @@ impl RaftStorage for Arc { async fn read_vote( &mut self, - ) -> Result>, StorageError> { + ) -> Result>, StorageError> { Ok(*self.vote.read().await) } #[tracing::instrument(level = "trace", skip(self, entries))] async fn append_to_log( &mut self, - entries: &[&Entry], - ) -> Result<(), StorageError> { + entries: &[&Entry], + ) -> Result<(), StorageError> { let mut log = self.log.write().await; for entry in entries { log.insert(entry.log_id.index, (*entry).clone()); @@ -333,8 +333,8 @@ impl RaftStorage for Arc { #[tracing::instrument(level = "debug", skip(self))] async fn delete_conflict_logs_since( &mut self, - log_id: LogId, - ) -> Result<(), StorageError> { + log_id: LogId, + ) -> Result<(), StorageError> { tracing::debug!("delete_log: [{:?}, +oo)", log_id); let mut log = self.log.write().await; @@ -352,8 +352,8 @@ impl RaftStorage for Arc { #[tracing::instrument(level = "debug", skip(self))] async fn purge_logs_upto( &mut self, - log_id: LogId, - ) -> Result<(), StorageError> { + log_id: LogId, + ) -> Result<(), StorageError> { tracing::debug!("delete_log: [{:?}, +oo)", log_id); { @@ -381,10 +381,10 @@ impl RaftStorage for Arc { &mut self, ) -> Result< ( - Option>, - StoredMembership, + Option>, + StoredMembership, ), - StorageError, + StorageError, > { let state_machine = self.state_machine.read().await; Ok(( @@ -396,8 +396,8 @@ impl RaftStorage for Arc { #[tracing::instrument(level = "trace", skip(self, entries))] async fn apply_to_state_machine( &mut self, - entries: &[&Entry], - ) -> Result, StorageError> { + entries: &[&Entry], + ) -> Result, StorageError> { let mut res = Vec::with_capacity(entries.len()); let mut sm = self.state_machine.write().await; @@ -408,9 +408,9 @@ impl RaftStorage for Arc { sm.last_applied_log = Some(entry.log_id); match entry.payload { - EntryPayload::Blank => res.push(ExampleResponse::Empty), + EntryPayload::Blank => res.push(DcacheResponse::Empty), EntryPayload::Normal(ref req) => match req { - ExampleRequest::AddVisitor(msg) => { + DcacheRequest::AddVisitor(msg) => { let r = sm .data .master @@ -421,9 +421,9 @@ impl RaftStorage for Arc { .unwrap() .unwrap(); - res.push(ExampleResponse::AddVisitorResult(r)); + res.push(DcacheResponse::AddVisitorResult(r)); } - ExampleRequest::AddCaptcha(msg) => { + DcacheRequest::AddCaptcha(msg) => { sm.data .master .send(msg.clone()) @@ -432,9 +432,9 @@ impl RaftStorage for Arc { .await .unwrap() .unwrap(); - res.push(ExampleResponse::Empty); + res.push(DcacheResponse::Empty); } - ExampleRequest::RenameCaptcha(msg) => { + DcacheRequest::RenameCaptcha(msg) => { sm.data .master .send(msg.clone()) @@ -443,9 +443,9 @@ impl RaftStorage for Arc { .await .unwrap() .unwrap(); - res.push(ExampleResponse::Empty); + res.push(DcacheResponse::Empty); } - ExampleRequest::RemoveCaptcha(msg) => { + DcacheRequest::RemoveCaptcha(msg) => { sm.data .master .send(msg.clone()) @@ -454,12 +454,12 @@ impl RaftStorage for Arc { .await .unwrap() .unwrap(); - res.push(ExampleResponse::Empty); + res.push(DcacheResponse::Empty); } }, EntryPayload::Membership(ref mem) => { sm.last_membership = StoredMembership::new(Some(entry.log_id), mem.clone()); - res.push(ExampleResponse::Empty) + res.push(DcacheResponse::Empty) } }; } @@ -469,22 +469,22 @@ impl RaftStorage for Arc { #[tracing::instrument(level = "trace", skip(self))] async fn begin_receiving_snapshot( &mut self, - ) -> Result, StorageError> { + ) -> Result, StorageError> { Ok(Box::new(Cursor::new(Vec::new()))) } #[tracing::instrument(level = "trace", skip(self, snapshot))] async fn install_snapshot( &mut self, - meta: &SnapshotMeta, + meta: &SnapshotMeta, snapshot: Box, - ) -> Result<(), StorageError> { + ) -> Result<(), StorageError> { tracing::info!( { snapshot_size = snapshot.get_ref().len() }, "decoding snapshot for installation" ); - let new_snapshot = ExampleSnapshot { + let new_snapshot = DcacheSnapshot { meta: meta.clone(), data: snapshot.into_inner(), }; @@ -517,8 +517,8 @@ impl RaftStorage for Arc { async fn get_current_snapshot( &mut self, ) -> Result< - Option>, - StorageError, + Option>, + StorageError, > { match &*self.current_snapshot.read().await { Some(snapshot) => {