Created a startup function for session.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
create::IndexType,
|
create::IndexType,
|
||||||
definition::{DocDef, DocFuncType},
|
definition::{DocDef, DocFuncType},
|
||||||
},
|
},
|
||||||
message::wrapper::Message,
|
message::{wrapper::Message, MessageID},
|
||||||
name::{Name, NameType},
|
name::{Name, NameType},
|
||||||
queue::{
|
queue::{
|
||||||
data_director::{Include, Path, RegMsg, Register},
|
data_director::{Include, Path, RegMsg, Register},
|
||||||
@@ -45,6 +45,23 @@ impl Session {
|
|||||||
names
|
names
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn start(mut queue: Queue) {
|
||||||
|
let (tx, rx) = channel();
|
||||||
|
let msg_id = MessageID::new();
|
||||||
|
let sender_id = queue.add_sender(tx);
|
||||||
|
let path = Path::new(
|
||||||
|
Include::Just(msg_id.clone()),
|
||||||
|
Include::All,
|
||||||
|
Include::Just(Action::DocumentCreated),
|
||||||
|
);
|
||||||
|
let reg_msg = Register::new(sender_id.clone(), RegMsg::AddRoute(path.clone()));
|
||||||
|
queue.send(Message::with_id(msg_id.clone(), reg_msg));
|
||||||
|
rx.recv().unwrap(); // Wait for completion.
|
||||||
|
queue.send(Message::with_id(msg_id, Self::document_definition()));
|
||||||
|
rx.recv().unwrap(); // Wait for completion.
|
||||||
|
queue.remove_sender(&sender_id);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn document_definition() -> DocDef {
|
pub fn document_definition() -> DocDef {
|
||||||
let name_id = Self::id_field_names()[0].clone();
|
let name_id = Self::id_field_names()[0].clone();
|
||||||
let name_expire = Self::expire_field_names()[0].clone();
|
let name_expire = Self::expire_field_names()[0].clone();
|
||||||
|
|||||||
14
src/lib.rs
14
src/lib.rs
@@ -218,15 +218,10 @@ pub struct MoreThanText {
|
|||||||
impl MoreThanText {
|
impl MoreThanText {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let queue = Queue::new();
|
let queue = Queue::new();
|
||||||
let mut output = Self {
|
CreateDoc::start(queue.clone()); // needs to be first.
|
||||||
queue: queue.clone(),
|
|
||||||
};
|
|
||||||
Clock::start(queue.clone());
|
Clock::start(queue.clone());
|
||||||
CreateDoc::start(queue.clone());
|
Session::start(queue.clone());
|
||||||
output
|
Self { queue: queue }
|
||||||
.create_document(Session::document_definition())
|
|
||||||
.unwrap();
|
|
||||||
output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn client(&self) -> MTTClient {
|
pub fn client(&self) -> MTTClient {
|
||||||
@@ -241,6 +236,7 @@ impl MoreThanText {
|
|||||||
MTTClient::new(self.queue.clone(), Some(id), lang)
|
MTTClient::new(self.queue.clone(), Some(id), lang)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /*
|
||||||
fn new_session(lang: Option<Language>) -> ClientAction {
|
fn new_session(lang: Option<Language>) -> ClientAction {
|
||||||
let mut output = Addition::new(Session::doc_names()[0].clone());
|
let mut output = Addition::new(Session::doc_names()[0].clone());
|
||||||
match lang {
|
match lang {
|
||||||
@@ -380,7 +376,7 @@ impl MoreThanText {
|
|||||||
self.queue.remove_sender(&sender_id);
|
self.queue.remove_sender(&sender_id);
|
||||||
output
|
output
|
||||||
}
|
}
|
||||||
|
// */
|
||||||
pub fn get_document(&self, name: &str, id: &str) -> Result<String, MTTError> {
|
pub fn get_document(&self, name: &str, id: &str) -> Result<String, MTTError> {
|
||||||
if name == "page" {
|
if name == "page" {
|
||||||
Ok("something".to_string())
|
Ok("something".to_string())
|
||||||
|
|||||||
Reference in New Issue
Block a user