use obufscated fmt() for Debug output
This commit is contained in:
parent
16c1218f0e
commit
f825b50387
|
@ -1239,7 +1239,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "geyser-grpc-connector"
|
name = "geyser-grpc-connector"
|
||||||
version = "0.7.1+yellowstone.1.11"
|
version = "0.7.2+yellowstone.1.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-stream",
|
"async-stream",
|
||||||
|
|
|
@ -3,7 +3,7 @@ use futures::{Stream, StreamExt};
|
||||||
use log::{debug, info, log, trace, warn, Level};
|
use log::{debug, info, log, trace, warn, Level};
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Display;
|
use std::fmt::{Debug, Display};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
use tokio::time::{sleep, timeout};
|
use tokio::time::{sleep, timeout};
|
||||||
|
@ -22,7 +22,7 @@ pub struct GrpcConnectionTimeouts {
|
||||||
pub subscribe_timeout: Duration,
|
pub subscribe_timeout: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone)]
|
||||||
pub struct GrpcSourceConfig {
|
pub struct GrpcSourceConfig {
|
||||||
grpc_addr: String,
|
grpc_addr: String,
|
||||||
grpc_x_token: Option<String>,
|
grpc_x_token: Option<String>,
|
||||||
|
@ -40,6 +40,12 @@ impl Display for GrpcSourceConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for GrpcSourceConfig {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
std::fmt::Display::fmt(&self, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl GrpcSourceConfig {
|
impl GrpcSourceConfig {
|
||||||
/// Create a grpc source without tls and timeouts
|
/// Create a grpc source without tls and timeouts
|
||||||
pub fn new_simple(grpc_addr: String) -> Self {
|
pub fn new_simple(grpc_addr: String) -> Self {
|
||||||
|
@ -257,3 +263,50 @@ pub fn create_geyser_reconnecting_stream(
|
||||||
|
|
||||||
the_stream
|
the_stream
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_debug_no_secrets() {
|
||||||
|
let timeout_config = GrpcConnectionTimeouts {
|
||||||
|
connect_timeout: Duration::from_secs(1),
|
||||||
|
request_timeout: Duration::from_secs(2),
|
||||||
|
subscribe_timeout: Duration::from_secs(3),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
format!(
|
||||||
|
"{:?}",
|
||||||
|
GrpcSourceConfig::new(
|
||||||
|
"http://localhost:1234".to_string(),
|
||||||
|
Some("my-secret".to_string()),
|
||||||
|
None,
|
||||||
|
timeout_config
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"grpc_addr http://localhost:1234"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_display_no_secrets() {
|
||||||
|
let timeout_config = GrpcConnectionTimeouts {
|
||||||
|
connect_timeout: Duration::from_secs(1),
|
||||||
|
request_timeout: Duration::from_secs(2),
|
||||||
|
subscribe_timeout: Duration::from_secs(3),
|
||||||
|
};
|
||||||
|
assert_eq!(
|
||||||
|
format!(
|
||||||
|
"{}",
|
||||||
|
GrpcSourceConfig::new(
|
||||||
|
"http://localhost:1234".to_string(),
|
||||||
|
Some("my-secret".to_string()),
|
||||||
|
None,
|
||||||
|
timeout_config
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"grpc_addr http://localhost:1234"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue