Moved include and path to data.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
@@ -1,58 +1,16 @@
|
||||
use crate::{mtterror::MTTError, message::{Action, DocRegistry, Message, RegMsg, Register}, name::NameType};
|
||||
use crate::{
|
||||
message::{DocRegistry, Message, RegMsg, Register},
|
||||
mtterror::MTTError,
|
||||
name::NameType,
|
||||
};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{
|
||||
mpsc::{channel, Sender},
|
||||
Arc, RwLock,
|
||||
},
|
||||
};
|
||||
use uuid::Uuid;
|
||||
use std::{collections::HashMap, sync::{mpsc::{Sender, channel}, Arc, RwLock}};
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash)]
|
||||
pub enum Include<T> {
|
||||
All,
|
||||
Just(T),
|
||||
}
|
||||
|
||||
impl<T: PartialEq> PartialEq for Include<T> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match self {
|
||||
Include::All => true,
|
||||
Include::Just(data) => match other {
|
||||
Include::All => true,
|
||||
Include::Just(other_data) => data == other_data,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod includes {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn does_all_equal_evberything() {
|
||||
let a: Include<isize> = Include::All;
|
||||
let b: Include<isize> = Include::Just(5);
|
||||
let c: Include<isize> = Include::Just(7);
|
||||
assert!(a == a, "all should equal all");
|
||||
assert!(a == b, "all should equal just");
|
||||
assert!(b == a, "just should equal all");
|
||||
assert!(b == b, "same just should equal");
|
||||
assert!(b != c, "different justs do not equal");
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Path {
|
||||
pub msg_id: Include<Uuid>,
|
||||
pub doc: Include<NameType>,
|
||||
pub action: Include<Action>,
|
||||
}
|
||||
|
||||
impl Path {
|
||||
pub fn new(id: Include<Uuid>, doc: Include<NameType>, action: Include<Action>) -> Self {
|
||||
Self {
|
||||
msg_id: id,
|
||||
doc: doc,
|
||||
action: action,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct Router {
|
||||
doc_registry: Sender<Message>,
|
||||
@@ -135,9 +93,13 @@ impl Queue {
|
||||
|
||||
#[cfg(test)]
|
||||
mod routers {
|
||||
use crate::{message::{MsgAction, Query}, name::Name, support_tests::TIMEOUT};
|
||||
use std::collections::HashSet;
|
||||
use super::*;
|
||||
use crate::{
|
||||
message::{MsgAction, Query},
|
||||
name::Name,
|
||||
support_tests::TIMEOUT,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
#[test]
|
||||
fn can_pass_message() {
|
||||
|
||||
Reference in New Issue
Block a user