Skip to content
Draft
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
8 changes: 8 additions & 0 deletions lading/src/generator/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ impl Grpc {
/// Function will panic if user has passed zero values for any byte
/// values. Sharp corners.
#[expect(clippy::cast_possible_truncation)]
#[expect(
clippy::expect_used,
reason = "FIXME: config.target_uri is user-supplied; parsing and the required path_and_query check should surface as Error variants instead of panicking. Tracked for follow-up."
)]
pub fn new(
general: General,
config: Config,
Expand Down Expand Up @@ -241,6 +245,10 @@ impl Grpc {
}

/// Establish a connection with the configured RPC server
#[expect(
clippy::expect_used,
reason = "Uri::from_parts is reconstructing self.target_uri's parts after replacing path_and_query with an empty static; the parts already came from a valid Uri"
)]
async fn connect(&self) -> Result<client::Grpc<transport::Channel>, Error> {
let mut parts = self.target_uri.clone().into_parts();
parts.path_and_query = Some(PathAndQuery::from_static(""));
Expand Down
8 changes: 8 additions & 0 deletions lading/src/generator/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ impl Http {
/// Function will panic if user has passed non-zero values for any byte
/// values. Sharp corners.
#[expect(clippy::cast_possible_truncation)]
#[expect(
clippy::expect_used,
reason = "OnceCell::set is called exactly once at HTTP generator startup"
)]
pub fn new(
general: General,
config: Config,
Expand Down Expand Up @@ -212,6 +216,10 @@ impl Http {
///
/// Function will panic if it is unable to create HTTP requests for the
/// target.
#[expect(
clippy::expect_used,
reason = "OnceCell::get on a value set during `new`, and Semaphore::acquire panics only after `Semaphore::close`; we never close the throttle semaphore"
)]
pub async fn spin(mut self) -> Result<(), Error> {
let client = Client::builder(TokioExecutor::new())
.pool_max_idle_per_host(self.concurrency.connection_count() as usize)
Expand Down
4 changes: 4 additions & 0 deletions lading/src/generator/kubernetes/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ impl Resource {
}
}

#[expect(
clippy::expect_used,
reason = "callers must set the name via `set_name` before calling `get_name`; this is a documented internal API contract"
)]
pub(super) fn get_name(&self) -> &str {
self.meta()
.name
Expand Down
9 changes: 6 additions & 3 deletions lading/src/generator/procfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ pub enum Error {

fn default_copy_from_host() -> Vec<PathBuf> {
vec![
PathBuf::from_str("/proc/uptime").expect("failed to convert /proc/uptime to PathBuf"),
PathBuf::from_str("/proc/stat").expect("failed to convert /proc/stat to PathBuf"),
PathBuf::from_str("/proc/uptime")
.unwrap_or_else(|_| unreachable!("\"/proc/uptime\" is a valid PathBuf")),
PathBuf::from_str("/proc/stat")
.unwrap_or_else(|_| unreachable!("\"/proc/stat\" is a valid PathBuf")),
]
}

Expand Down Expand Up @@ -141,7 +143,8 @@ impl ProcFs {
}

// SAFETY: By construction this pathbuf cannot fail to be created.
let prefix = PathBuf::from_str("/proc").expect("failed to convert /proc to PathBuf");
let prefix = PathBuf::from_str("/proc")
.unwrap_or_else(|_| unreachable!("\"/proc\" is a valid PathBuf"));

for path in &config.copy_from_host {
let base = path.strip_prefix(&prefix)?;
Expand Down
12 changes: 12 additions & 0 deletions lading/src/generator/splunk_hec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ impl SplunkHec {
/// Function will panic if user has passed non-zero values for any byte
/// values. Sharp corners.
#[expect(clippy::cast_possible_truncation)]
#[expect(
clippy::expect_used,
reason = "OnceCell::set is called exactly once at Splunk HEC generator startup"
)]
pub fn new(
general: General,
config: Config,
Expand Down Expand Up @@ -267,6 +271,10 @@ impl SplunkHec {
///
/// Function will panic if it is unable to create HTTP requests for the
/// target.
#[expect(
clippy::expect_used,
reason = "channel iterator is constructed from a non-empty Vec; OnceCell::get and Semaphore::acquire follow the same contract as the HTTP generator"
)]
pub async fn spin(mut self) -> Result<(), Error> {
let client = Client::builder(TokioExecutor::new())
.pool_max_idle_per_host(self.parallel_connections as usize)
Expand Down Expand Up @@ -339,6 +347,10 @@ impl SplunkHec {
}

#[expect(clippy::too_many_arguments)]
#[expect(
clippy::expect_used,
reason = "FIXME: server response parsing on Splunk HEC ack-id should surface as an Error variant rather than panic on malformed remote responses. Tracked for follow-up."
)]
async fn send_hec_request<B>(
permit: SemaphorePermit<'_>,
block_length: usize,
Expand Down
4 changes: 4 additions & 0 deletions lading/src/generator/splunk_hec/acknowledgements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl Channel {
}
}

#[expect(
clippy::expect_used,
reason = "callers route Some(ack_id) producers into Channel::Ack; the None branch is unreachable per the worker/ack-service contract"
)]
pub(crate) async fn send<Fut>(&self, msg: Fut) -> Result<(), Error>
where
Fut: Future<Output = Option<AckId>>,
Expand Down
10 changes: 7 additions & 3 deletions lading/src/generator/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ impl Tcp {
/// Function will panic if user has passed zero values for any byte
/// values. Sharp corners.
#[expect(clippy::cast_possible_truncation)]
#[expect(
clippy::expect_used,
reason = "FIXME: config.addr is user-supplied; socket address parsing failures should surface as Error variants instead of panicking. Tracked for follow-up."
)]
pub fn new(
general: General,
config: &Config,
Expand Down Expand Up @@ -168,9 +172,9 @@ impl Tcp {
for i in 0..worker_count {
let throttle =
create_throttle(config.throttle.as_ref(), config.bytes_per_second.as_ref())?
.divide(
NonZeroU32::new(worker_count.into()).expect("worker_count is always >= 1"),
)?;
.divide(NonZeroU32::new(worker_count.into()).unwrap_or_else(|| {
unreachable!("worker_count is NonZeroU16, always >= 1")
}))?;

let mut worker_labels = labels.clone();
if worker_count > 1 {
Expand Down
Loading