Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Commit 76cc045

Browse files
authored
refactor!: make idempotency_token private (#306)
1 parent f4bb3ed commit 76cc045

File tree

2 files changed

+2
-86
lines changed

2 files changed

+2
-86
lines changed

src/types.rs

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -872,14 +872,7 @@ pub struct CreateBasinInput {
872872
///
873873
/// Defaults to [`AwsUsEast1`](BasinScope::AwsUsEast1).
874874
pub scope: Option<BasinScope>,
875-
/// Idempotency token for the operation.
876-
///
877-
/// When a request is retried, the same token is reused,
878-
/// causing the server to return the original response instead of
879-
/// performing the operation again.
880-
///
881-
/// Defaults to a random UUID.
882-
pub idempotency_token: String,
875+
idempotency_token: String,
883876
}
884877

885878
impl CreateBasinInput {
@@ -908,14 +901,6 @@ impl CreateBasinInput {
908901
..self
909902
}
910903
}
911-
912-
/// Set the idempotency token for the operation.
913-
pub fn with_idempotency_token(self, idempotency_token: impl Into<String>) -> Self {
914-
Self {
915-
idempotency_token: idempotency_token.into(),
916-
..self
917-
}
918-
}
919904
}
920905

921906
impl From<CreateBasinInput> for (api::basin::CreateBasinRequest, String) {
@@ -2551,14 +2536,7 @@ pub struct CreateStreamInput {
25512536
///
25522537
/// See [`StreamConfig`] for defaults.
25532538
pub config: Option<StreamConfig>,
2554-
/// Idempotency token for the operation.
2555-
///
2556-
/// When a request is retried, the same token is reused,
2557-
/// causing the server to return the original response instead of
2558-
/// performing the operation again.
2559-
///
2560-
/// Defaults to a random UUID.
2561-
pub idempotency_token: String,
2539+
idempotency_token: String,
25622540
}
25632541

25642542
impl CreateStreamInput {
@@ -2578,14 +2556,6 @@ impl CreateStreamInput {
25782556
..self
25792557
}
25802558
}
2581-
2582-
/// Set the idempotency token for the operation.
2583-
pub fn with_idempotency_token(self, idempotency_token: impl Into<String>) -> Self {
2584-
Self {
2585-
idempotency_token: idempotency_token.into(),
2586-
..self
2587-
}
2588-
}
25892559
}
25902560

25912561
impl From<CreateStreamInput> for (api::stream::CreateStreamRequest, String) {

tests/basin_ops.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -735,60 +735,6 @@ async fn create_stream_delete_on_empty_min_age(basin: &SharedS2Basin) -> Result<
735735
Ok(())
736736
}
737737

738-
#[test_context(SharedS2Basin)]
739-
#[tokio_shared_rt::test(shared)]
740-
async fn create_stream_idempotent_same_token(basin: &SharedS2Basin) -> Result<(), S2Error> {
741-
let stream_name = unique_stream_name();
742-
let token = uuid();
743-
744-
let info_1 = basin
745-
.create_stream(
746-
CreateStreamInput::new(stream_name.clone()).with_idempotency_token(token.clone()),
747-
)
748-
.await?;
749-
let info_2 = basin
750-
.create_stream(CreateStreamInput::new(stream_name.clone()).with_idempotency_token(token))
751-
.await?;
752-
753-
assert_eq!(info_1.name, stream_name);
754-
assert_eq!(info_2.name, stream_name);
755-
756-
basin
757-
.delete_stream(DeleteStreamInput::new(stream_name))
758-
.await?;
759-
760-
Ok(())
761-
}
762-
763-
#[test_context(SharedS2Basin)]
764-
#[tokio_shared_rt::test(shared)]
765-
async fn create_stream_idempotent_different_token_errors(
766-
basin: &SharedS2Basin,
767-
) -> Result<(), S2Error> {
768-
let stream_name = unique_stream_name();
769-
770-
basin
771-
.create_stream(CreateStreamInput::new(stream_name.clone()).with_idempotency_token(uuid()))
772-
.await?;
773-
774-
let result = basin
775-
.create_stream(CreateStreamInput::new(stream_name.clone()).with_idempotency_token(uuid()))
776-
.await;
777-
778-
assert_matches!(
779-
result,
780-
Err(S2Error::Server(ErrorResponse { code, .. })) => {
781-
assert_eq!(code, "resource_already_exists");
782-
}
783-
);
784-
785-
basin
786-
.delete_stream(DeleteStreamInput::new(stream_name))
787-
.await?;
788-
789-
Ok(())
790-
}
791-
792738
#[test_context(SharedS2Basin)]
793739
#[tokio_shared_rt::test(shared)]
794740
async fn create_stream_invalid_retention_age_zero(basin: &SharedS2Basin) -> Result<(), S2Error> {

0 commit comments

Comments
 (0)