Jetstream, Tracing, basic ingestor + tracing
I'm mainly just commiting this so I can work on my laptop, but I'm too tired to manage branches and then later rebasing things
This commit is contained in:
parent
c0c90c3001
commit
028219ded1
6 changed files with 135 additions and 82 deletions
|
|
@ -1,8 +1,5 @@
|
|||
use atrium_api::types::string::{
|
||||
AtIdentifier,
|
||||
RecordKey,
|
||||
};
|
||||
use regex::Regex;
|
||||
use atrium_api::types::string::RecordKey;
|
||||
// use regex::Regex;
|
||||
|
||||
pub use atrium_api::types::string::{
|
||||
Nsid,
|
||||
|
|
@ -15,10 +12,10 @@ enum Authority {
|
|||
Handle(Handle),
|
||||
}
|
||||
|
||||
impl Authority {
|
||||
pub fn new(authority: String) -> Result<Self, &'static str> {
|
||||
}
|
||||
}
|
||||
// impl Authority {
|
||||
// pub fn new(authority: String) -> Result<Self, &'static str> {
|
||||
// }
|
||||
// }
|
||||
|
||||
// This implementation does not support Query or Fragments, and thus follows
|
||||
// the following schema: "at://" AUTHORITY [ "/" COLLECTION [ "/" RKEY ] ]
|
||||
|
|
@ -29,42 +26,42 @@ pub struct Uri {
|
|||
}
|
||||
|
||||
// TODO: Replace super basic URI regex with real uri parsing
|
||||
const URI_REGEX: Regex = Regex::new(
|
||||
r"/^at:\/\/([\w\.\-_~:]+)(?:\/([\w\.\-_~:]+)(?:)\/([\w\.\-_~:]+))?$/i"
|
||||
).expect("valid regex");
|
||||
|
||||
impl Uri {
|
||||
pub fn new(uri: String) -> Result<Self, &'static str> {
|
||||
let Some(captures) = URI_REGEX.captures(&uri) else {
|
||||
return Err("Invalid Uri");
|
||||
};
|
||||
// TODO: Convert authority if its a did or a handle
|
||||
let Some(Ok(authority)) = captures.get(1).map(|mtch| {
|
||||
Authority::new(mtch.as_str().to_string())
|
||||
}) else {
|
||||
return Err("Invalid Authority")
|
||||
};
|
||||
let collection = captures.get(2).map(|mtch| {
|
||||
Nsid::new(mtch.as_str().to_string())
|
||||
});
|
||||
let rkey = captures.get(3).map(|mtch| {
|
||||
RecordKey::new(mtch.as_str().to_string())
|
||||
});
|
||||
Ok(Uri { authority, collection, rkey })
|
||||
}
|
||||
|
||||
pub fn as_string(&self) -> String {
|
||||
let mut uri = String::from("at://");
|
||||
uri.push_str(match &self.authority {
|
||||
Authority::Handle(h) => &*h,
|
||||
Authority::Did(d) => &*d,
|
||||
});
|
||||
if let Some(nsid) = &self.collection {
|
||||
uri.push_str(&*nsid);
|
||||
}
|
||||
if let Some(rkey) = &self.rkey {
|
||||
uri.push_str(&*rkey);
|
||||
}
|
||||
uri
|
||||
}
|
||||
}
|
||||
// const URI_REGEX: Regex = Regex::new(
|
||||
// r"/^at:\/\/([\w\.\-_~:]+)(?:\/([\w\.\-_~:]+)(?:)\/([\w\.\-_~:]+))?$/i"
|
||||
// ).expect("valid regex");
|
||||
//
|
||||
// impl Uri {
|
||||
// pub fn new(uri: String) -> Result<Self, &'static str> {
|
||||
// let Some(captures) = URI_REGEX.captures(&uri) else {
|
||||
// return Err("Invalid Uri");
|
||||
// };
|
||||
// // TODO: Convert authority if its a did or a handle
|
||||
// let Some(Ok(authority)) = captures.get(1).map(|mtch| {
|
||||
// Authority::new(mtch.as_str().to_string())
|
||||
// }) else {
|
||||
// return Err("Invalid Authority")
|
||||
// };
|
||||
// let collection = captures.get(2).map(|mtch| {
|
||||
// Nsid::new(mtch.as_str().to_string())
|
||||
// });
|
||||
// let rkey = captures.get(3).map(|mtch| {
|
||||
// RecordKey::new(mtch.as_str().to_string())
|
||||
// });
|
||||
// Ok(Uri { authority, collection, rkey })
|
||||
// }
|
||||
//
|
||||
// pub fn as_string(&self) -> String {
|
||||
// let mut uri = String::from("at://");
|
||||
// uri.push_str(match &self.authority {
|
||||
// Authority::Handle(h) => &*h,
|
||||
// Authority::Did(d) => &*d,
|
||||
// });
|
||||
// if let Some(nsid) = &self.collection {
|
||||
// uri.push_str(&*nsid);
|
||||
// }
|
||||
// if let Some(rkey) = &self.rkey {
|
||||
// uri.push_str(&*rkey);
|
||||
// }
|
||||
// uri
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue