rename client id -> client key
This commit is contained in:
@@ -4,10 +4,10 @@ use std::collections::HashMap;
|
||||
use std::sync::{Mutex, MutexGuard};
|
||||
|
||||
struct Inner {
|
||||
/// Clients, indexed by client_id
|
||||
/// Clients, indexed by client_key
|
||||
clients: HashMap<Uuid, Client>,
|
||||
|
||||
/// Versions, indexed by (client_id, parent_version_id)
|
||||
/// Versions, indexed by (client_key, parent_version_id)
|
||||
versions: HashMap<(Uuid, Uuid), Version>,
|
||||
}
|
||||
|
||||
@@ -34,48 +34,48 @@ impl Storage for InMemoryStorage {
|
||||
}
|
||||
|
||||
impl<'a> StorageTxn for InnerTxn<'a> {
|
||||
fn get_client(&mut self, client_id: Uuid) -> Fallible<Option<Client>> {
|
||||
Ok(self.0.clients.get(&client_id).cloned())
|
||||
fn get_client(&mut self, client_key: Uuid) -> Fallible<Option<Client>> {
|
||||
Ok(self.0.clients.get(&client_key).cloned())
|
||||
}
|
||||
|
||||
fn new_client(&mut self, client_id: Uuid, latest_version_id: Uuid) -> Fallible<()> {
|
||||
if self.0.clients.get(&client_id).is_some() {
|
||||
return Err(format_err!("Client {} already exists", client_id));
|
||||
fn new_client(&mut self, client_key: Uuid, latest_version_id: Uuid) -> Fallible<()> {
|
||||
if self.0.clients.get(&client_key).is_some() {
|
||||
return Err(format_err!("Client {} already exists", client_key));
|
||||
}
|
||||
self.0
|
||||
.clients
|
||||
.insert(client_id, Client { latest_version_id });
|
||||
.insert(client_key, Client { latest_version_id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_client_latest_version_id(
|
||||
&mut self,
|
||||
client_id: Uuid,
|
||||
client_key: Uuid,
|
||||
latest_version_id: Uuid,
|
||||
) -> Fallible<()> {
|
||||
if let Some(client) = self.0.clients.get_mut(&client_id) {
|
||||
if let Some(client) = self.0.clients.get_mut(&client_key) {
|
||||
client.latest_version_id = latest_version_id;
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format_err!("Client {} does not exist", client_id))
|
||||
Err(format_err!("Client {} does not exist", client_key))
|
||||
}
|
||||
}
|
||||
|
||||
fn get_version_by_parent(
|
||||
&mut self,
|
||||
client_id: Uuid,
|
||||
client_key: Uuid,
|
||||
parent_version_id: Uuid,
|
||||
) -> Fallible<Option<Version>> {
|
||||
Ok(self
|
||||
.0
|
||||
.versions
|
||||
.get(&(client_id, parent_version_id))
|
||||
.get(&(client_key, parent_version_id))
|
||||
.cloned())
|
||||
}
|
||||
|
||||
fn add_version(
|
||||
&mut self,
|
||||
client_id: Uuid,
|
||||
client_key: Uuid,
|
||||
version_id: Uuid,
|
||||
parent_version_id: Uuid,
|
||||
history_segment: Vec<u8>,
|
||||
@@ -88,7 +88,7 @@ impl<'a> StorageTxn for InnerTxn<'a> {
|
||||
};
|
||||
self.0
|
||||
.versions
|
||||
.insert((client_id, version.parent_version_id), version);
|
||||
.insert((client_key, version.parent_version_id), version);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user