Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on tracing-valuable #157

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .cargo/config.toml

This file was deleted.

15 changes: 0 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ tracing = { version = "0.1.40", features = [
"async-await",
"log",
"release_max_level_debug",
"valuable",
] }
tracing-subscriber = { version = "0.3.16", features = ["env-filter", "fmt"] }
tracing-unwrap = "1.0.1"
valuable = { version = "0.1.0", features = ["derive"] }
which = "6.0.1"
xz2 = { version = "0.1.7", features = ["static"] }

Expand Down
9 changes: 2 additions & 7 deletions src/childproc_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use serde::de::DeserializeOwned;
use std::fmt::Debug;
use tracing::{error, info};
use tracing_unwrap::ResultExt;
use valuable::Valuable;

use crate::logging::init_logging_child;

Expand All @@ -18,7 +17,7 @@ use crate::logging::init_logging_child;
/// - Get the child-specific config from arg 3
///
/// This returns the socket path and the child-specific config.
pub fn child_init<C: DeserializeOwned + Debug + Valuable>() -> (String, C) {
pub fn child_init<C: DeserializeOwned + Debug>() -> (String, C) {
let cli_args: Vec<String> = env::args().collect();

// We will set up logging first because if any part of this godforsaken
Expand All @@ -31,11 +30,7 @@ pub fn child_init<C: DeserializeOwned + Debug + Valuable>() -> (String, C) {

let socket_path = &cli_args[2];
let args = serde_json::from_str::<C>(&cli_args[3]).unwrap_or_log();
info!(
?socket_path,
args = args.as_value(),
"We are in child process mode"
);
info!(?socket_path, ?args, "We are in child process mode");

(socket_path.clone(), args)
}
3 changes: 1 addition & 2 deletions src/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
};

use serde::{Deserialize, Serialize};
use valuable::Valuable;

macro_rules! generate {
{
Expand Down Expand Up @@ -47,7 +46,7 @@ macro_rules! generate {
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum CompressionFormat {
Identity,
$(
Expand Down
3 changes: 1 addition & 2 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use std::{

use bytesize::ByteSize;
use serde::{Deserialize, Serialize};
use valuable::Valuable;

#[cfg(target_os = "linux")]
pub fn enumerate_devices() -> impl Iterator<Item = WriteTarget> {
Expand Down Expand Up @@ -307,7 +306,7 @@ impl Display for Removable {
}
}

#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize, Valuable)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
pub enum Type {
File,
Disk,
Expand Down
5 changes: 2 additions & 3 deletions src/escalated_daemon/ipc.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use serde::{Deserialize, Serialize};
use valuable::Valuable;

use crate::writer_process::ipc::WriterProcessConfig;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct EscalatedDaemonInitConfig {
// Okay, there's nothing here right now, but there might be someday!
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SpawnWriter {
pub log_file: String,
pub init_config: WriterProcessConfig,
Expand Down
3 changes: 1 addition & 2 deletions src/escalated_daemon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use interprocess::local_socket::{tokio::prelude::*, GenericFilePath};
use tokio::io::{AsyncBufRead, BufReader};
use tracing::{error, info, info_span, Instrument};
use tracing_unwrap::ResultExt;
use valuable::Valuable;

use crate::{
childproc_common::child_init,
Expand Down Expand Up @@ -51,7 +50,7 @@ pub async fn main() {
async fn event_loop(socket: &str, mut stream: impl AsyncBufRead + Unpin) -> anyhow::Result<()> {
loop {
let msg = read_msg_async::<SpawnWriter>(&mut stream).await?;
info!(msg = msg.as_value(), "Received SpawnWriter request");
info!(?msg, "Received SpawnWriter request");

let command =
make_writer_spawn_command(socket.into(), msg.log_file.into(), &msg.init_config);
Expand Down
3 changes: 1 addition & 2 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use digest::Digest;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
use std::io::Read;
use valuable::Valuable;

macro_rules! generate {
{$(
Expand All @@ -17,7 +16,7 @@ macro_rules! generate {
})*
]
)*} => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum HashAlg {
$($(
$enum_arm,
Expand Down
3 changes: 1 addition & 2 deletions src/run_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{borrow::Cow, fmt::Debug};

use process_path::get_executable_path;
use serde::Serialize;
use valuable::Valuable;

use crate::{
escalated_daemon::ipc::EscalatedDaemonInitConfig, escalation::Command,
Expand Down Expand Up @@ -67,7 +66,7 @@ impl RunMode {
}

/// Build a [Command] that, when run, spawns a process with a specific configuration.
pub fn make_spawn_command<'a, C: Serialize + Debug + Valuable>(
pub fn make_spawn_command<'a, C: Serialize + Debug>(
socket: Cow<'a, str>,
log_path: Cow<'a, str>,
run_mode: RunMode,
Expand Down
6 changes: 1 addition & 5 deletions src/ui/herder/herder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::{
use anyhow::Context;
use interprocess::local_socket::tokio::prelude::*;
use tracing::{debug, trace};
use valuable::Valuable;

use crate::escalation::run_escalate;
use crate::writer_process::ipc::{StatusMessage, WriterProcessConfig};
Expand Down Expand Up @@ -109,10 +108,7 @@ impl Herder {

trace!("Reading results from child");
let first_msg = read_msg_async::<StatusMessage>(&mut handle.rx).await?;
debug!(
first_msg = first_msg.as_value(),
"Read raw result from child"
);
debug!(?first_msg, "Read raw result from child");

let initial_info = match first_msg {
StatusMessage::InitSuccess(i) => Ok(i),
Expand Down
10 changes: 4 additions & 6 deletions src/writer_process/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ use std::{fmt::Display, path::PathBuf};

use serde::{Deserialize, Serialize};

use valuable::Valuable;

use crate::compression::CompressionFormat;
use crate::device::Type;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct WriterProcessConfig {
pub dest: PathBuf,
pub src: PathBuf,
Expand All @@ -17,7 +15,7 @@ pub struct WriterProcessConfig {
pub block_size: Option<u64>,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum StatusMessage {
InitSuccess(InitialInfo),
TotalBytes {
Expand All @@ -37,12 +35,12 @@ pub enum StatusMessage {
Error(ErrorType),
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct InitialInfo {
pub input_file_bytes: u64,
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Valuable)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ErrorType {
EndOfOutput,
PermissionDenied,
Expand Down