From d27db21bbe6375f41d02bb5e2cff84f39c8e32e5 Mon Sep 17 00:00:00 2001 From: pretentious7 Date: Wed, 10 Jan 2024 11:26:19 -0500 Subject: [PATCH] Some debug derivations and implementations (#545) This is just to be able to stick tracing::instrument in places, it's especially useful to be able to do this on TypedSocketSender::send --- plane/src/drone/docker/mod.rs | 2 +- plane/src/typed_socket/mod.rs | 8 +++++++- plane/src/util.rs | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/plane/src/drone/docker/mod.rs b/plane/src/drone/docker/mod.rs index 62b91e3e3..8159dfbda 100644 --- a/plane/src/drone/docker/mod.rs +++ b/plane/src/drone/docker/mod.rs @@ -17,7 +17,7 @@ pub mod types; /// The existence of this label is used to determine whether a container is managed by Plane. const PLANE_DOCKER_LABEL: &str = "dev.plane.backend"; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct PlaneDocker { docker: Docker, runtime: Option, diff --git a/plane/src/typed_socket/mod.rs b/plane/src/typed_socket/mod.rs index 64c8619cd..5453f388e 100644 --- a/plane/src/typed_socket/mod.rs +++ b/plane/src/typed_socket/mod.rs @@ -30,6 +30,12 @@ pub struct TypedSocketSender { Arc) -> Result<(), TypedSocketError> + 'static + Send + Sync>, } +impl Debug for TypedSocketSender { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str("typed socket sender") + } +} + #[derive(Debug, thiserror::Error)] pub enum TypedSocketError { #[error("Socket closed")] @@ -47,7 +53,7 @@ impl From> for TypedSocketError { } } -impl TypedSocketSender { +impl TypedSocketSender { pub fn send(&self, message: A) -> Result<(), TypedSocketError> { (self.inner_send)(SocketAction::Send(message))?; Ok(()) diff --git a/plane/src/util.rs b/plane/src/util.rs index d6b3baa26..76f99d3f0 100644 --- a/plane/src/util.rs +++ b/plane/src/util.rs @@ -137,6 +137,7 @@ impl Default for ExponentialBackoff { } } +#[derive(Debug)] pub struct GuardHandle { handle: JoinHandle<()>, }