server_storage core topic OKM object key/col/value mapping

pull/19/head
Niko PLP 6 months ago
parent 5b9c1d67fd
commit 4ba34c7300
  1. 4
      ng-broker/src/server_broker.rs
  2. 31
      ng-broker/src/server_storage/core/topic.rs
  3. 2
      ng-net/src/actors/client/pin_repo.rs
  4. 14
      ng-repo/src/kcv_storage.rs

@ -21,14 +21,14 @@ use ng_repo::{
use crate::rocksdb_server_storage::RocksDbServerStorage;
struct TopicInfo {
pub struct TopicInfo {
repo: RepoHash,
publisher_advert: Option<PublisherAdvert>,
current_heads: HashSet<ObjectId>,
expose_outer: bool,
root_commit: Option<ObjectId>,
/// indicates which users have opened the topic (boolean says if as publisher or not)
users: HashMap<UserId, bool>,

@ -19,6 +19,8 @@ use ng_repo::types::*;
use serde_bare::to_vec;
use crate::server_broker::TopicInfo;
pub struct Topic<'a> {
key: Vec<u8>,
repo: ExistentialValue<RepoHash>,
@ -60,18 +62,23 @@ impl<'a> Topic<'a> {
vec![&Self::USERS, &Self::HEADS],
);
pub fn load(&self) -> Result<(), StorageError> {
let props = self.load_props()?;
// let bs = BranchInfo {
// id: id.clone(),
// branch_type: prop(Self::TYPE, &props)?,
// read_cap: prop(Self::READ_CAP, &props)?,
// topic: prop(Self::TOPIC, &props)?,
// topic_priv_key: prop(Self::PUBLISHER, &props).ok(),
// current_heads: Self::get_all_heads(id, storage)?,
// };
// Ok(bs)
Ok(())
pub fn load(
id: &TopicId,
overlay: &OverlayId,
storage: &'a dyn KCVStorage,
) -> Result<TopicInfo, StorageError> {
let mut opening = Topic::new(id, overlay, storage);
let props = opening.load_props()?;
let existential = col(&Self::REPO, &props)?;
opening.repo.set(&existential, &opening)?;
let ti = TopicInfo {
repo: existential,
publisher_advert: col(&Self::ADVERT, &props).ok(),
root_commit: col(&Self::ROOT_COMMIT, &props).ok(),
users: Self::USERS.get_all(&mut opening)?,
current_heads: Self::HEADS.get_all(&mut opening)?,
};
Ok(ti)
}
pub fn new(id: &TopicId, overlay: &OverlayId, storage: &'a dyn KCVStorage) -> Self {

@ -48,7 +48,7 @@ impl PinRepo {
expose_outer: false,
peers: vec![],
max_peer_count: 0,
allowed_peers: vec![],
//allowed_peers: vec![],
ro_topics,
rw_topics,
})

@ -24,6 +24,20 @@ where
)?)
}
pub fn col<A>(
column: &dyn ISingleValueColumn,
props: &HashMap<u8, Vec<u8>>,
) -> Result<A, StorageError>
where
A: for<'a> Deserialize<'a>,
{
Ok(from_slice(
&props
.get(&column.suffix())
.ok_or(StorageError::PropertyNotFound)?,
)?)
}
pub struct Class<'a> {
columns: Vec<&'a dyn ISingleValueColumn>,
multi_value_columns: Vec<&'a dyn IMultiValueColumn>,

Loading…
Cancel
Save