Added Jenkins file
This commit is contained in:
parent
734fc3ba2d
commit
ba875ea171
27
Jenkinsfile
vendored
Normal file
27
Jenkinsfile
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Rust Testing') {
|
||||||
|
steps {
|
||||||
|
sh "cargo test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Linux Build') {
|
||||||
|
steps {
|
||||||
|
sh "cargo build --release"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Integration Testing') {
|
||||||
|
steps {
|
||||||
|
sh "pipenv install"
|
||||||
|
sh "pipenv run pytest"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Archiving') {
|
||||||
|
steps {
|
||||||
|
archiveArtifacts artifacts: 'target/release/morethantext_web', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/lib.rs
19
src/lib.rs
@ -14,6 +14,7 @@ use uuid::Uuid;
|
|||||||
pub struct MoreThanText {
|
pub struct MoreThanText {
|
||||||
id: Option<Uuid>,
|
id: Option<Uuid>,
|
||||||
tx: Sender<SendMsg>,
|
tx: Sender<SendMsg>,
|
||||||
|
nodes: Vec<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MoreThanText {
|
impl MoreThanText {
|
||||||
@ -24,15 +25,15 @@ impl MoreThanText {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use morethantext::MoreThanText;
|
/// use morethantext::MoreThanText;
|
||||||
///
|
///
|
||||||
/// MoreThanText::new();
|
/// MoreThanText::new(Vec::new());
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new() -> Self {
|
pub fn new(_nodes: Vec<String>) -> Self {
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
spawn(move || {
|
spawn(move || {
|
||||||
let mut cache = Cache::new(rx);
|
let mut cache = Cache::new(rx);
|
||||||
cache.listen();
|
cache.listen();
|
||||||
});
|
});
|
||||||
Self { id: None, tx: tx }
|
Self { id: None, tx: tx, nodes: Vec::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens an existing or new session with the database.
|
/// Opens an existing or new session with the database.
|
||||||
@ -45,7 +46,7 @@ impl MoreThanText {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use morethantext::MoreThanText;
|
/// use morethantext::MoreThanText;
|
||||||
///
|
///
|
||||||
/// let mut mtt = MoreThanText::new();
|
/// let mut mtt = MoreThanText::new(Vec::new());
|
||||||
/// mtt.open_session(None);
|
/// mtt.open_session(None);
|
||||||
/// mtt.open_session(Some("7b1ff340-7dfa-4f29-b144-601384e54423".to_string()));
|
/// mtt.open_session(Some("7b1ff340-7dfa-4f29-b144-601384e54423".to_string()));
|
||||||
/// ```
|
/// ```
|
||||||
@ -65,7 +66,7 @@ impl MoreThanText {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use morethantext::MoreThanText;
|
/// use morethantext::MoreThanText;
|
||||||
///
|
///
|
||||||
/// let mut mtt = MoreThanText::new();
|
/// let mut mtt = MoreThanText::new(Vec::new());
|
||||||
/// mtt.get_id();
|
/// mtt.get_id();
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_id(&self) -> String {
|
pub fn get_id(&self) -> String {
|
||||||
@ -82,7 +83,7 @@ mod mtt_client {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn uniques_ids() {
|
fn uniques_ids() {
|
||||||
let mut mtt = MoreThanText::new();
|
let mut mtt = MoreThanText::new(Vec::new());
|
||||||
let mut ids: Vec<Uuid> = Vec::new();
|
let mut ids: Vec<Uuid> = Vec::new();
|
||||||
for _ in 1..10 {
|
for _ in 1..10 {
|
||||||
mtt.open_session(None);
|
mtt.open_session(None);
|
||||||
@ -96,7 +97,7 @@ mod mtt_client {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn existing_ids_are_reused() {
|
fn existing_ids_are_reused() {
|
||||||
let mut mtt = MoreThanText::new();
|
let mut mtt = MoreThanText::new(Vec::new());
|
||||||
mtt.open_session(None);
|
mtt.open_session(None);
|
||||||
let holder = mtt.id.clone().unwrap().to_string();
|
let holder = mtt.id.clone().unwrap().to_string();
|
||||||
mtt.open_session(Some(holder.clone()));
|
mtt.open_session(Some(holder.clone()));
|
||||||
@ -105,14 +106,14 @@ mod mtt_client {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bad_ids_generate_new_ones() {
|
fn bad_ids_generate_new_ones() {
|
||||||
let mut mtt = MoreThanText::new();
|
let mut mtt = MoreThanText::new(Vec::new());
|
||||||
mtt.open_session(Some("bad test string".to_string()));
|
mtt.open_session(Some("bad test string".to_string()));
|
||||||
assert!(mtt.id.is_some());
|
assert!(mtt.id.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn incorrect_ids_generate_new_ones() {
|
fn incorrect_ids_generate_new_ones() {
|
||||||
let mut mtt = MoreThanText::new();
|
let mut mtt = MoreThanText::new(Vec::new());
|
||||||
let holder = Uuid::new_v4();
|
let holder = Uuid::new_v4();
|
||||||
mtt.open_session(Some(holder.clone().to_string()));
|
mtt.open_session(Some(holder.clone().to_string()));
|
||||||
assert_ne!(mtt.id, Some(holder));
|
assert_ne!(mtt.id, Some(holder));
|
||||||
|
@ -18,7 +18,7 @@ struct Args {
|
|||||||
address: String,
|
address: String,
|
||||||
/// cluster host
|
/// cluster host
|
||||||
#[arg(short, long, num_args(0..))]
|
#[arg(short, long, num_args(0..))]
|
||||||
cluster: Option<String>,
|
node: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -33,7 +33,8 @@ mod http_session {
|
|||||||
async fn main() {
|
async fn main() {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let addr = format!("{}:{}", args.address, args.port);
|
let addr = format!("{}:{}", args.address, args.port);
|
||||||
let state = MoreThanText::new();
|
let nodes = args.node;
|
||||||
|
let state = MoreThanText::new(nodes);
|
||||||
let app = Router::new().route("/", get(handler)).with_state(state);
|
let app = Router::new().route("/", get(handler)).with_state(state);
|
||||||
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||||
axum::serve(listener, app.into_make_service())
|
axum::serve(listener, app.into_make_service())
|
||||||
|
Loading…
Reference in New Issue
Block a user