Skip to content

Commit baacfc5

Browse files
Merge pull request #2 from mayakerostasia/githubActions
GitHub actions but some of them fail... That'll be ok for now since we're just adding the actions
2 parents a8ff6af + fdc154f commit baacfc5

File tree

16 files changed

+484
-405
lines changed

16 files changed

+484
-405
lines changed

.github/workflows/msvc.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
on: push
2+
name: stable-beta-nightly
3+
4+
jobs:
5+
ci:
6+
runs-on: ubuntu-latest
7+
strategy:
8+
matrix:
9+
rust:
10+
- stable
11+
- beta
12+
- nightly
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions-rs/toolchain@v1
17+
with:
18+
profile: minimal
19+
toolchain: ${{ matrix.rust }}
20+
override: true
21+
components: rustfmt, clippy
22+
23+
- uses: actions-rs/cargo@v1
24+
with:
25+
command: check
26+
27+
- uses: actions-rs/cargo@v1
28+
with:
29+
command: fmt
30+
args: --all -- --check
31+
32+
- uses: actions-rs/cargo@v1
33+
with:
34+
command: clippy
35+
args: -- -D warnings
36+

.github/workflows/test.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
on: [push, pull_request]
2+
3+
name: Rust Check/Test/Fmt
4+
5+
jobs:
6+
check:
7+
name: Check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions-rs/toolchain@v1
12+
with:
13+
profile: minimal
14+
toolchain: stable
15+
override: true
16+
- uses: actions-rs/cargo@v1
17+
with:
18+
command: check
19+
20+
test:
21+
name: Test Suite
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions-rs/toolchain@v1
26+
with:
27+
profile: minimal
28+
toolchain: stable
29+
override: true
30+
- uses: actions-rs/cargo@v1
31+
with:
32+
command: test
33+
34+
fmt:
35+
name: Rustfmt
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions-rs/toolchain@v1
40+
with:
41+
profile: minimal
42+
toolchain: stable
43+
override: true
44+
- run: rustup component add rustfmt
45+
- uses: actions-rs/cargo@v1
46+
with:
47+
command: fmt
48+
args: --all -- --check
49+
50+
clippy:
51+
name: Clippy
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- uses: actions-rs/toolchain@v1
56+
with:
57+
profile: minimal
58+
toolchain: stable
59+
override: true
60+
- run: rustup component add clippy
61+
- uses: actions-rs/cargo@v1
62+
with:
63+
command: clippy
64+
args: -- -D warnings

src/atomics/mod.rs

Lines changed: 60 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,60 @@
1-
use std::fmt::Display;
2-
use serde_json::{Value, json};
3-
use serde::{Serialize, Deserialize};
4-
use crate::cli::Upload;
5-
6-
#[derive(Debug, Clone, Serialize, Deserialize)]
7-
pub struct Atomic {
8-
id: IdQuark,
9-
meta: MetaQuark,
10-
data: DataQuark,
11-
}
12-
13-
impl Atomic {
14-
pub fn get_data(&self) -> Value {
15-
self.data.0.clone()
16-
}
17-
18-
pub fn from_array_in_object(_array_field: &str, _value: Value) -> Self {
19-
todo!()
20-
}
21-
22-
pub fn basic_value(value: Value) -> Self {
23-
Atomic {
24-
id: IdQuark("".to_string()),
25-
meta: MetaQuark(json!({})),
26-
data: DataQuark(value)
27-
}
28-
}
29-
}
30-
31-
impl From<Value> for Atomic {
32-
fn from(value: Value) -> Self {
33-
Atomic::basic_value(value)
34-
}
35-
36-
}
37-
impl From<Upload> for Atomic {
38-
fn from(value: Upload) -> Self {
39-
let data = value.get_data();
40-
data.into()
41-
}
42-
43-
}
44-
impl Display for Atomic {
45-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
46-
f.write_str(&serde_json::to_string(self).expect("Failed to stringify Atomic"))
47-
}
48-
}
49-
50-
// impl Store for Atomic {
51-
// async fn store_object(index: String, input: Atomic) -> Result<(), Error> {
52-
// todo!()
53-
// }
54-
// }
55-
#[derive(Debug, Clone, Serialize, Deserialize)]
56-
pub struct IdQuark(String);
57-
58-
#[derive(Debug, Clone, Serialize, Deserialize)]
59-
pub struct DataQuark(Value);
60-
61-
#[derive(Debug, Clone, Serialize, Deserialize)]
62-
pub struct MetaQuark(Value);
1+
use crate::cli::Upload;
2+
use serde::{Deserialize, Serialize};
3+
use serde_json::{Value, json};
4+
use std::fmt::Display;
5+
6+
#[derive(Debug, Clone, Serialize, Deserialize)]
7+
pub struct Atomic {
8+
id: IdQuark,
9+
meta: MetaQuark,
10+
data: DataQuark,
11+
}
12+
13+
impl Atomic {
14+
pub fn get_data(&self) -> Value {
15+
self.data.0.clone()
16+
}
17+
18+
pub fn from_array_in_object(_array_field: &str, _value: Value) -> Self {
19+
todo!()
20+
}
21+
22+
pub fn basic_value(value: Value) -> Self {
23+
Atomic {
24+
id: IdQuark("".to_string()),
25+
meta: MetaQuark(json!({})),
26+
data: DataQuark(value),
27+
}
28+
}
29+
}
30+
31+
impl From<Value> for Atomic {
32+
fn from(value: Value) -> Self {
33+
Atomic::basic_value(value)
34+
}
35+
}
36+
impl From<Upload> for Atomic {
37+
fn from(value: Upload) -> Self {
38+
let data = value.get_data();
39+
data.into()
40+
}
41+
}
42+
impl Display for Atomic {
43+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44+
f.write_str(&serde_json::to_string(self).expect("Failed to stringify Atomic"))
45+
}
46+
}
47+
48+
// impl Store for Atomic {
49+
// async fn store_object(index: String, input: Atomic) -> Result<(), Error> {
50+
// todo!()
51+
// }
52+
// }
53+
#[derive(Debug, Clone, Serialize, Deserialize)]
54+
pub struct IdQuark(String);
55+
56+
#[derive(Debug, Clone, Serialize, Deserialize)]
57+
pub struct DataQuark(Value);
58+
59+
#[derive(Debug, Clone, Serialize, Deserialize)]
60+
pub struct MetaQuark(Value);

src/bin/tee_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clap::Parser;
33
use document_storage::{
44
cli::{Commands, QuickwitUploader, ServiceType, Upload},
55
storage::{
6-
Search, Store,
6+
Store,
77
opensearch::{OpenSearchService, OpensearchAtom},
88
quickwit::{Quickwit, QuickwitAtom},
99
},

src/cli/mod.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
use clap::{Parser, Subcommand};
2-
pub use upload::Upload;
3-
pub use search::Search;
4-
pub use services::ServiceType;
5-
6-
mod upload;
7-
mod search;
8-
mod services;
9-
10-
const VERSION: &str = env!("CARGO_PKG_VERSION");
11-
const ABOUT: &str = "Quickwit Pipe Uploader";
12-
const LONG_ABOUT: &str = r#"
13-
This is a CLI for Piping JSON data to quickwit.
14-
It allows you to take output from another command and uploads it to quickwit.
15-
"#;
16-
17-
#[derive(Parser, Debug)]
18-
#[command(version = VERSION, about = ABOUT, long_about = LONG_ABOUT)]
19-
pub struct QuickwitUploader {
20-
#[command(subcommand)]
21-
pub command: Option<Commands>,
22-
}
23-
24-
#[derive(Debug, Subcommand)]
25-
pub enum Commands {
26-
Upload(Upload),
27-
Search(Search),
28-
}
29-
1+
use clap::{Parser, Subcommand};
2+
pub use search::Search;
3+
pub use services::ServiceType;
4+
pub use upload::Upload;
5+
6+
mod search;
7+
mod services;
8+
mod upload;
9+
10+
const VERSION: &str = env!("CARGO_PKG_VERSION");
11+
const ABOUT: &str = "Quickwit Pipe Uploader";
12+
const LONG_ABOUT: &str = r#"
13+
This is a CLI for Piping JSON data to quickwit.
14+
It allows you to take output from another command and uploads it to quickwit.
15+
"#;
16+
17+
#[derive(Parser, Debug)]
18+
#[command(version = VERSION, about = ABOUT, long_about = LONG_ABOUT)]
19+
pub struct QuickwitUploader {
20+
#[command(subcommand)]
21+
pub command: Option<Commands>,
22+
}
23+
24+
#[derive(Debug, Subcommand)]
25+
pub enum Commands {
26+
Upload(Upload),
27+
Search(Search),
28+
}

src/cli/search.rs

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,51 @@
1-
2-
use std::fmt::Display;
3-
use clap::Args;
4-
use serde_json::Value;
5-
6-
use super::ServiceType;
7-
8-
#[derive(Args, Debug)]
9-
#[command(
10-
version,
11-
about = "Document Search",
12-
long_about = r#"Search database for documents"#
13-
)]
14-
pub struct Search {
15-
#[arg(short, long)]
16-
query: String,
17-
#[arg(short, long)]
18-
index: String,
19-
#[arg(short, long)]
20-
pub server: Option<ServiceType>
21-
}
22-
23-
impl Search {
24-
pub fn get_query(&self) -> String {
25-
self.query.clone()
26-
}
27-
28-
pub fn get_index(&self) -> String {
29-
self.index.clone()
30-
}
31-
}
32-
33-
// impl Display for Search {
34-
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35-
// let data_value = match &self.field {
36-
// Some(fld) => {
37-
// match self.data.get(fld) {
38-
// Some(val) => val.clone(),
39-
// None => panic!("Field ({:?}) not found in data, or isn't an array", fld)
40-
// }
41-
// },
42-
// None => {
43-
// assert!(self.data.is_array());
44-
// self.data.clone().into_inner()
45-
// }
46-
// };
47-
// let data_array = data_value.as_array().unwrap();
48-
// for val in data_array {
49-
// f.write_str(&serde_json::to_string(val).unwrap()).unwrap();
50-
// f.write_str("\n").unwrap();
51-
// };
52-
// Ok(())
53-
// }
54-
// }
1+
use clap::Args;
2+
3+
use super::ServiceType;
4+
5+
#[derive(Args, Debug)]
6+
#[command(
7+
version,
8+
about = "Document Search",
9+
long_about = r#"Search database for documents"#
10+
)]
11+
pub struct Search {
12+
#[arg(short, long)]
13+
query: String,
14+
#[arg(short, long)]
15+
index: String,
16+
#[arg(short, long)]
17+
pub server: Option<ServiceType>,
18+
}
19+
20+
impl Search {
21+
pub fn get_query(&self) -> String {
22+
self.query.clone()
23+
}
24+
25+
pub fn get_index(&self) -> String {
26+
self.index.clone()
27+
}
28+
}
29+
30+
// impl Display for Search {
31+
// fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32+
// let data_value = match &self.field {
33+
// Some(fld) => {
34+
// match self.data.get(fld) {
35+
// Some(val) => val.clone(),
36+
// None => panic!("Field ({:?}) not found in data, or isn't an array", fld)
37+
// }
38+
// },
39+
// None => {
40+
// assert!(self.data.is_array());
41+
// self.data.clone().into_inner()
42+
// }
43+
// };
44+
// let data_array = data_value.as_array().unwrap();
45+
// for val in data_array {
46+
// f.write_str(&serde_json::to_string(val).unwrap()).unwrap();
47+
// f.write_str("\n").unwrap();
48+
// };
49+
// Ok(())
50+
// }
51+
// }

0 commit comments

Comments
 (0)