Skip to content

Commit b66b045

Browse files
committed
refactor(php): carry the non-zero retry interval types
The consumer builder takes NonZeroIggyDuration for the retry intervals, so the binding's own zero check hands that type over.
1 parent 3548468 commit b66b045

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

foreign/php/src/client.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,8 @@ impl IggyClient {
343343
builder = builder.auto_commit(auto_commit.into());
344344
}
345345
builder = match poll_interval_micros {
346-
Some(micros) => {
347-
builder.poll_interval(non_zero_duration_micros("poll_interval_micros", micros)?)
348-
}
346+
Some(micros) => builder
347+
.poll_interval(non_zero_duration_micros("poll_interval_micros", micros)?.get()),
349348
None => builder.without_poll_interval(),
350349
};
351350
if let Some(micros) = polling_retry_interval_micros {
@@ -408,12 +407,7 @@ impl IggyClient {
408407
}
409408
}
410409

411-
fn non_zero_duration_micros(field: &str, micros: u64) -> PhpResult<IggyDuration> {
412-
if micros == 0 {
413-
return Err(to_php_exception(format!(
414-
"'{field}' must be greater than 0 microseconds"
415-
)));
416-
}
417-
418-
Ok(IggyDuration::from(micros))
410+
fn non_zero_duration_micros(field: &str, micros: u64) -> PhpResult<NonZeroIggyDuration> {
411+
NonZeroIggyDuration::try_from(micros)
412+
.map_err(|_| to_php_exception(format!("'{field}' must be greater than 0 microseconds")))
419413
}

0 commit comments

Comments
 (0)