-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a77dd2
commit ab6b937
Showing
7 changed files
with
113 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
workspace = { members = ["mrecordlog_cli"] } | ||
[package] | ||
name = "mrecordlog" | ||
version = "0.4.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# --- Builder | ||
|
||
FROM rust:bullseye AS bin-builder | ||
|
||
COPY . /mrecordlog | ||
|
||
WORKDIR /mrecordlog/mrecordlog_cli | ||
|
||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/mrecordlog/target \ | ||
cargo build --release --bin mrecordlog && \ | ||
ls /mrecordlog/target/release && \ | ||
mkdir -p /quickwit/bin && \ | ||
mv /mrecordlog/target/release/mrecordlog /quickwit/bin/mrecordlog | ||
|
||
# --- ACTUAL image. | ||
|
||
FROM debian:bullseye-slim AS quickwit | ||
|
||
LABEL org.opencontainers.image.title="Quickwit MRecordlog utils CLI" | ||
LABEL maintainer="Quickwit, Inc. <[email protected]>" | ||
LABEL org.opencontainers.image.vendor="Quickwit, Inc." | ||
LABEL org.opencontainers.image.licenses="AGPL-3.0" | ||
|
||
WORKDIR /quickwit | ||
|
||
COPY --from=bin-builder /quickwit/bin/mrecordlog /usr/local/bin/mrecordlog | ||
|
||
ENTRYPOINT ["mrecordlog"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "mrecordlog_cli" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
mrecordlog = { path = "../" } | ||
anyhow = "*" | ||
structopt = "0.3" | ||
|
||
[[bin]] | ||
name = "mrecordlog" | ||
path = "src/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use std::path::{Path, PathBuf}; | ||
|
||
use mrecordlog::MultiRecordLog; | ||
use structopt::StructOpt; | ||
|
||
#[derive(Debug, StructOpt)] | ||
enum Command { | ||
Summary { | ||
#[structopt(short)] | ||
wal_path: PathBuf, | ||
}, | ||
Read { | ||
#[structopt(short)] | ||
wal_path: PathBuf, | ||
#[structopt(short)] | ||
queue_name: String, | ||
}, | ||
} | ||
|
||
fn run_summary(path: &Path) -> anyhow::Result<()> { | ||
let multi_record_log = MultiRecordLog::open(path)?; | ||
let summary = multi_record_log.summary(); | ||
for (queue, summary) in summary.queues { | ||
println!("{}", queue); | ||
println!("{summary:?}"); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn run_read_queue(path: &Path, queue_name: &str) -> anyhow::Result<()> { | ||
let multi_record_log = MultiRecordLog::open(path)?; | ||
for record in multi_record_log.range(queue_name, ..)? { | ||
let Ok(payload_str) = std::str::from_utf8(&record.payload) else { | ||
eprintln!("Payload is not utf8: {:?}", record.payload); | ||
continue; | ||
}; | ||
println!("{payload_str}"); | ||
} | ||
Ok(()) | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let command = Command::from_args(); | ||
match command { | ||
Command::Summary { wal_path } => { | ||
run_summary(&wal_path)?; | ||
} | ||
Command::Read { | ||
queue_name, | ||
wal_path, | ||
} => { | ||
run_read_queue(&wal_path, &queue_name)?; | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.