Skip to content

Commit 46105ca

Browse files
committed
Based on review comments, the following changes have been made:
- Updated change logs to mention unreleased - Removed all functions list from the README.md - Renaming examples to samples to match pattern in other languages - Removed singular helper functions and exists helper functions - Adjusting code based on update to the dependencies - Changed StorageServiceProperties to QueueServiceProperties - Exposing clients and client options from the crate root
1 parent d0cb3da commit 46105ca

23 files changed

+322
-484
lines changed

sdk/storage/azure_storage_queue/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Release History
22

3-
## 0.1.0 (2025-06-17)
3+
## 0.1.0 (Unreleased)
44

55
### Features Added
66

sdk/storage/azure_storage_queue/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ documentation = "https://docs.rs/azure_storage_queue"
1313
keywords = ["sdk", "azure", "storage", "queue", "queues"]
1414
categories = ["api-bindings"]
1515

16+
# Manual example definitions pointing to samples/ directory
17+
[[example]]
18+
name = "queue_client"
19+
path = "samples/queue_client.rs"
20+
21+
[[example]]
22+
name = "queue_service_client"
23+
path = "samples/queue_service_client.rs"
24+
1625
[features]
1726
default = ["reqwest"]
1827
reqwest = ["dep:reqwest"]

sdk/storage/azure_storage_queue/README.md

Lines changed: 6 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ az storage account create -n my-storage-account-name -g my-resource-group
3939
In order to interact with the Azure Queue service, you'll need to create an instance of a client, `QueueClient`. The [Azure Identity] library makes it easy to add Microsoft Entra ID support for authenticating Azure SDK clients with their corresponding Azure services:
4040

4141
```rust no_run
42-
use azure_storage_queue::clients::{QueueClient, QueueClientOptions};
42+
use azure_storage_queue::{QueueClient, QueueClientOptions};
4343
use azure_identity::DefaultAzureCredential;
4444

4545
#[tokio::main]
@@ -60,70 +60,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6060

6161
You may need to specify RBAC roles to access Queues via Microsoft Entra ID. Please see [Assign an Azure role for access to queue data] for more details.
6262

63-
## Features
64-
65-
### QueueServiceClient
66-
67-
The `QueueServiceClient` provides operations to interact with the Azure Storage Queue service at the account level.
68-
69-
| Method | Parameters | Return Type | Description |
70-
|-----------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
71-
| `new` | `endpoint: &str`<br>`credential: Arc<dyn TokenCredential>`<br>`options: Option<QueueServiceClientOptions>` | `Result<Self>` | Creates a new QueueServiceClient using Entra ID authentication |
72-
| `endpoint` | `&self` | `&Url` | Returns the endpoint URL of the Azure storage account |
73-
| `queue_client` | `&self`<br>`queue_name: String` | `QueueClient` | Returns a new QueueClient instance for a specific queue |
74-
| `create_queue` | `&self`<br>`queue_name: &str`<br>`options: Option<QueueClientCreateOptions<'_>>` | `Result<Response<(), NoFormat>>` | Creates a new queue under the account |
75-
| `delete_queue` | `&self`<br>`queue_name: &str`<br>`options: Option<QueueClientDeleteOptions<'_>>` | `Result<Response<(), NoFormat>>` | Permanently deletes the specified queue |
76-
| `get_properties` | `&self`<br>`options: Option<QueueServiceClientGetPropertiesOptions<'_>>` | `Result<Response<StorageServiceProperties, XmlFormat>>` | Retrieves the properties of the queue service |
77-
| `set_properties` | `&self`<br>`storage_service_properties: RequestContent<StorageServiceProperties>`<br>`options: Option<QueueServiceClientSetPropertiesOptions<'_>>` | `Result<Response<(), NoFormat>>` | Sets the properties of the queue service |
78-
| `list_queues` | `&self`<br>`options: Option<QueueServiceClientListQueuesOptions<'_>>` | `Result<PageIterator<Response<ListQueuesResponse, XmlFormat>>>` | Lists queues in the storage account with pagination |
79-
| `get_statistics` | `&self`<br>`options: Option<QueueServiceClientGetStatisticsOptions<'_>>` | `Result<Response<StorageServiceStats, XmlFormat>>` | Retrieves statistics related to replication for the Queue service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the storage account |
80-
81-
---
82-
83-
### QueueClient
84-
85-
The `QueueClient` provides operations to interact with a specific Azure Storage Queue.
86-
87-
| Method | Parameters | Return Type | Description |
88-
|--------------|---------------------------------------------------------------------------------------------------------------------------|----------------|--------------------------------------------------------------|
89-
| `new` | `endpoint: &str`<br>`queue_name: &str`<br>`credential: Arc<dyn TokenCredential>`<br>`options: Option<QueueClientOptions>` | `Result<Self>` | Creates a new QueueClient using Entra ID authentication |
90-
| `endpoint` | `&self` | `&Url` | Returns the endpoint URL of the Azure storage account |
91-
| `queue_name` | `&self` | `&str` | Returns the name of the queue this client is associated with |
92-
93-
#### Queue Management
94-
95-
| Method | Parameters | Return Type | Description |
96-
|------------------------|------------------------------------------------------------|----------------------------------|---------------------------------------------|
97-
| `create` | `&self`<br>`options: Option<QueueClientCreateOptions<'_>>` | `Result<Response<(), NoFormat>>` | Creates a new queue |
98-
| `create_if_not_exists` | `&self`<br>`options: Option<QueueClientCreateOptions<'_>>` | `Result<Response<(), NoFormat>>` | Creates a queue if it doesn't already exist |
99-
| `delete` | `&self`<br>`options: Option<QueueClientDeleteOptions<'_>>` | `Result<Response<(), NoFormat>>` | Permanently deletes the queue |
100-
| `delete_if_exists` | `&self`<br>`options: Option<QueueClientDeleteOptions<'_>>` | `Result<Response<(), NoFormat>>` | Deletes the queue if it exists |
101-
| `exists` | `&self` | `Result<bool>` | Checks if the queue exists |
102-
| `clear` | `&self`<br>`options: Option<QueueClientClearOptions<'_>>` | `Result<Response<(), NoFormat>>` | Clears all messages in the queue |
103-
104-
#### Metadata Operations
105-
106-
| Method | Parameters | Return Type | Description |
107-
|----------------|-----------------------------------------------------------------|------------------------------------------------------------|-------------------------------------|
108-
| `set_metadata` | `&self`<br>`options: Option<QueueClientSetMetadataOptions<'_>>` | `Result<Response<(), NoFormat>>` | Sets the metadata for the queue |
109-
| `get_metadata` | `&self`<br>`options: Option<QueueClientGetMetadataOptions<'_>>` | `Result<Response<QueueClientGetMetadataResult, NoFormat>>` | Retrieves the metadata of the queue |
110-
111-
#### Message Operations
112-
113-
| Method | Parameters | Return Type | Description |
114-
|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------|---------------------------------------------------------|
115-
| `send_message` | `&self`<br>`queue_message: RequestContent<QueueMessage>`<br>`options: Option<QueueClientSendMessageOptions<'_>>` | `Result<Response<Option<SentMessage>, XmlFormat>>` | Sends a message to the queue |
116-
| `receive_message` | `&self`<br>`options: Option<QueueClientReceiveMessagesOptions<'_>>` | `Result<Response<Option<ReceivedMessage>, XmlFormat>>` | Retrieves a single message from the front of the queue |
117-
| `receive_messages` | `&self`<br>`options: Option<QueueClientReceiveMessagesOptions<'_>>` | `Result<Response<ListOfReceivedMessage, XmlFormat>>` | Retrieves multiple messages from the front of the queue |
118-
| `peek_message` | `&self`<br>`options: Option<QueueClientPeekMessagesOptions<'_>>` | `Result<Response<Option<PeekedMessage>, XmlFormat>>` | Peeks a single message without removing it |
119-
| `peek_messages` | `&self`<br>`options: Option<QueueClientPeekMessagesOptions<'_>>` | `Result<Response<ListOfPeekedMessage, XmlFormat>>` | Peeks multiple messages without removing them |
120-
| `delete_message` | `&self`<br>`message_id: &str`<br>`pop_receipt: &str`<br>`options: Option<QueueClientDeleteMessageOptions<'_>>` | `Result<Response<(), NoFormat>>` | Deletes a specific message from the queue |
121-
| `update_message` | `&self`<br>`message_id: &str`<br>`pop_receipt: &str`<br>`visibility_timeout: i32`<br>`options: Option<QueueClientUpdateOptions<'_>>` | `Result<Response<(), NoFormat>>` | Updates a specific message in the queue |
122-
12363
## Examples
12464

125-
<!-- TODO: Update the link below when the PR is merged -->
126-
Executable examples of all the functions provided by this SDK can be found in the [queue_client.rs]<!--(https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_queue/examples/queue_client.rs)--> file in the examples directory.
65+
<!-- TODO: Uncomment the links below when the PR is merged -->
66+
You can find executable examples for all major SDK functions in:
67+
- [queue_client.rs]<!--(https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_queue/samples/queue_client.rs)-->
68+
- [queue_service_client.rs]<!--(https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_queue/samples/queue_service_client.rs)-->
12769

12870
## Next steps
12971

@@ -139,7 +81,7 @@ When you submit a pull request, a CLA-bot will automatically determine whether y
13981

14082
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
14183

142-
<!-- TODO: Update the links below when the crate is published -->
84+
<!-- TODO: Uncomment the links below when the PR is merged -->
14385
<!-- LINKS -->
14486
[Azure subscription]: https://azure.microsoft.com/free/
14587
[Azure storage account]: https://learn.microsoft.com/azure/storage/common/storage-account-overview
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "rust",
4-
"Tag": "rust/azure_storage_queue_d6e20c5b11",
4+
"Tag": "rust/azure_storage_queue_12276aa05a",
55
"TagPrefix": "rust/azure_storage_queue"
66
}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Generates a random queue name with a suffix to ensure uniqueness.
22
pub fn get_random_queue_name() -> String {
33
use rand::Rng;
4-
let mut rng = rand::thread_rng();
5-
let random_suffix: u32 = rng.gen_range(1000..9999);
4+
let mut rng = rand::rng();
5+
let random_suffix: u32 = rng.random_range(1000..9999);
66
format!("sdk-test-queue-{}", random_suffix)
77
}

sdk/storage/azure_storage_queue/examples/queue_client.rs renamed to sdk/storage/azure_storage_queue/samples/queue_client.rs

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use azure_core::{
1111
};
1212
use azure_identity::DefaultAzureCredential;
1313
use azure_storage_queue::{
14-
clients::QueueClient,
1514
models::{
1615
QueueClientGetMetadataResultHeaders, QueueClientPeekMessagesOptions,
1716
QueueClientReceiveMessagesOptions, QueueClientSetMetadataOptions, QueueClientUpdateOptions,
1817
QueueMessage, SentMessage,
1918
},
19+
QueueClient,
2020
};
2121

2222
async fn send_message(
@@ -169,56 +169,6 @@ async fn peek_and_receive_messages(
169169
Ok(())
170170
}
171171

172-
async fn peek_and_receive_message(
173-
queue_client: &QueueClient,
174-
) -> Result<(), Box<dyn std::error::Error>> {
175-
_ = send_message(queue_client, "Message 1 from Rust Queue SDK").await;
176-
_ = send_message(queue_client, "Message 2 from Rust Queue SDK").await;
177-
178-
let options = QueueClientPeekMessagesOptions {
179-
number_of_messages: Some(5),
180-
..Default::default()
181-
};
182-
183-
let result = queue_client.peek_message(Some(options)).await;
184-
log_operation_result(&result, "peek_message");
185-
186-
if let Ok(response) = result {
187-
let message = response.into_body().await?;
188-
if let Some(message) = message {
189-
println!(
190-
"Successfully peeked message ({}): {}",
191-
message.message_id.unwrap(),
192-
message.message_text.unwrap_or_default()
193-
);
194-
}
195-
}
196-
197-
loop {
198-
let result = queue_client.receive_message(None).await;
199-
log_operation_result(&result, "receive_message");
200-
201-
if let Ok(response) = result {
202-
let message = response.into_body().await?;
203-
if let Some(msg) = message {
204-
println!(
205-
"Successfully received message ({}): {}",
206-
msg.message_id.unwrap(),
207-
msg.message_text.unwrap_or_default()
208-
);
209-
} else {
210-
// No more messages available
211-
break;
212-
}
213-
} else {
214-
// Error occurred, break the loop
215-
break;
216-
}
217-
}
218-
219-
Ok(())
220-
}
221-
222172
#[tokio::main]
223173
async fn main() -> Result<(), Box<dyn std::error::Error>> {
224174
let credential = DefaultAzureCredential::new()?;
@@ -236,9 +186,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
236186
let result = queue_client.exists().await;
237187
log_operation_result(&result, "check_exists");
238188

239-
let result = queue_client.create_if_not_exists(None).await;
240-
log_operation_result(&result, "create_if_not_exists");
241-
242189
// Set and get queue metadata
243190
set_and_get_metadata(&queue_client).await?;
244191

@@ -265,9 +212,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
265212
// Peek and Receive messages
266213
peek_and_receive_messages(&queue_client).await?;
267214

268-
// Peek and Receive message
269-
peek_and_receive_message(&queue_client).await?;
270-
271215
// Cleanup
272216
let result = queue_client.delete(None).await;
273217
log_operation_result(&result, "delete");
@@ -277,8 +221,5 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
277221
let result = non_existing_queue_client.exists().await;
278222
log_operation_result(&result, "check_non_existent");
279223

280-
let result = non_existing_queue_client.delete_if_exists(None).await;
281-
log_operation_result(&result, "delete_if_exists");
282-
283224
Ok(())
284225
}

0 commit comments

Comments
 (0)