-
Notifications
You must be signed in to change notification settings - Fork 297
Added sdk/storage/azure_storage_queue (#2730) #2732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements initial support for the 2018-03-28 Queue API in the Azure Storage Queue SDK for Rust. Key changes include the introduction of new client functions for managing queues, a comprehensive test suite covering the new operations, and several example programs and documentation updates.
Reviewed Changes
Copilot reviewed 18 out of 36 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
sdk/storage/azure_storage_queue/tsp-location.yaml | Adds configuration metadata for the queue API |
sdk/storage/azure_storage_queue/tests/queue_service_client.rs | Introduces recorded tests for queue service |
sdk/storage/azure_storage_queue/src/lib.rs | Sets up module exports for clients and models |
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs | Implements QueueServiceClient API functions |
sdk/storage/azure_storage_queue/examples/* | Provides usage examples and helper functions |
sdk/storage/azure_storage_queue/Cargo.toml | Configures the crate with required dependencies and features |
sdk/storage/azure_storage_queue/CHANGELOG.md | Documents the initial supported release |
sdk/storage/assets.json | Updates asset references |
sdk/storage/.dict.txt | Updates custom dictionary with new terms |
Cargo.toml | Adds the queue SDK to the workspace members |
Comments suppressed due to low confidence (1)
sdk/storage/azure_storage_queue/src/clients/queue_service_client.rs:90
- The documentation for the 'queue_name' parameter in the delete_queue function incorrectly states that it is 'to create' the queue. Please update the description to indicate that it is the name of the queue to delete.
/// * `queue_name` - The name of the queue to create
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
24925f4
to
ce518e5
Compare
Fixes #2708 Added support for the 2018-03-28 Queue API. The following functions have been created on the new QueueClient, roughly following the pattern in the .Net SDK: queue_client: new create create_if_not_exists clear delete delete_if_exists delete_message exists get_metadata get_properties enqueue_message dequeue_message dequeue_messages peek_message peek_messages set_metadata update_message get_access_policy set_access_policy queue_service_client: new create_queue delete_queue get_properties set_properties list_queues_segment (paginated) Examples of how to use each method has been provided in the ~/sdk/storage/examples/queue_client.rs file. Recorded tests has also been pushed to the repo Azure/azure-sdk-assets and the assets.json updated. The client is generated using tsp-client using remote Azure/azure-rest-api-specs repo.
* Regenerated client based on new TSP * Switching set and get metadata to use the generated client. * Added get_statistics * Updated samples to show how to pass realistic parameters.
ce518e5
to
1833dda
Compare
…json for the queue crate. Removing access policy api as there is issue with (de)serialization and this is also not yet implemented in blob.
1833dda
to
114ff2e
Compare
@@ -0,0 +1,7 @@ | |||
# Release History | |||
|
|||
## 0.1.0 (2025-06-17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably set this date to "Unreleased" for now.
|
||
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. | ||
|
||
## Features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably omit this section outlining all the methods. This would be hard to maintain and should be covered by docs.
@@ -0,0 +1,10 @@ | |||
# Storage Queue Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the name of this whole folder to samples
instead of examples
. This just matches the pattern we follow in our other languages.
/// | ||
/// Returns a `Result` containing the response. If the queue already exists, | ||
/// returns a success response with no content (204 No Content) | ||
pub async fn create_if_not_exists( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some consideration, I think maybe we should remove all the "exists" type methods for now. (with the exception of the plain exists
method below). They cannot be generated, and we are still discussing whether we want to introduce these types of methods in Rust across all of packages. Our different languages differ in whether they are included or not.
pub async fn exists(&self) -> Result<bool> { | ||
match self.get_metadata(None).await { | ||
Ok(_) => Ok(true), | ||
Err(e) if e.http_status().unwrap() == StatusCode::NotFound => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This exists is fine to have)
We don't want to use unwrap
in any production code was we don't want to ever panic.
/// # Errors | ||
/// | ||
/// Returns an error if the queue doesn't exist or if the request fails | ||
pub async fn receive_message( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for now let's omit the "single" message APIs where we call the plural one with number_of_messages
set to 1. To me, they don't add much value as the customer could just call the plural one themselves and parse the response. I know they exist in .NET, but I'm not sure they are really needed. Also, these are methods that cannot be generated. If we get feedback that they are needed, we can consider adding them back via extension methods.
Are these things that your team would really need?
/// Returns a `Result` containing the response if successful. | ||
pub async fn set_properties( | ||
&self, | ||
storage_service_properties: RequestContent<StorageServiceProperties>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this model to just QueueServiceProperties
? This would also change get_properties
. This can be done in the TypeSpec and we will do the same for Blob. Don't make the TypeSpec change specific to Rust, fine to completely rename the model.
mod queue_service_client; | ||
pub use self::queue_client::QueueClient; | ||
pub use self::queue_service_client::QueueServiceClient; | ||
pub use crate::generated::clients::{QueueClientOptions, QueueServiceClientOptions}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The clients and client options should be exported from the root of the crate, not inside a clients module.
|
||
/// Attempts to receive the first message from an empty queue in Azure Storage Queue service. | ||
#[recorded::test] | ||
async fn test_dequeue_message_empty(ctx: TestContext) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the dequeue test to match the APi, receive_message
.
Please note if you rename or delete tests, its best to manually remove the old recordings from the assets. Unfortunately, this does not happen automatically.
@@ -0,0 +1,4 @@ | |||
directory: specification/storage/Azure.Storage.Queues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the TypeSpec in the old folder location, Microsoft.QueueStorage
?
Fixes #2708
Added support for the 2018-03-28 Queue API. The following functions have been created on the new QueueClient, roughly following the pattern in the .Net SDK:
QueueServiceClient
The
QueueServiceClient
provides operations to interact with the Azure Storage Queue service at the account level.new
endpoint: &str
credential: Arc<dyn TokenCredential>
options: Option<QueueServiceClientOptions>
Result<Self>
endpoint
&self
&Url
queue_client
&self
queue_name: String
QueueClient
create_queue
&self
queue_name: &str
options: Option<QueueClientCreateOptions<'_>>
Result<Response<(), NoFormat>>
delete_queue
&self
queue_name: &str
options: Option<QueueClientDeleteOptions<'_>>
Result<Response<(), NoFormat>>
get_properties
&self
options: Option<QueueServiceClientGetPropertiesOptions<'_>>
Result<Response<StorageServiceProperties, XmlFormat>>
set_properties
&self
storage_service_properties: RequestContent<StorageServiceProperties>
options: Option<QueueServiceClientSetPropertiesOptions<'_>>
Result<Response<(), NoFormat>>
list_queues_segment
&self
options: Option<QueueServiceClientListQueuesSegmentOptions<'_>>
Result<PageIterator<Response<ListQueuesSegmentResponse, XmlFormat>>>
get_statistics
&self
options: Option<QueueServiceClientGetStatisticsOptions<'_>>
Result<Response<StorageServiceStats, XmlFormat>>
QueueClient
The
QueueClient
provides operations to interact with a specific Azure Storage Queue.new
endpoint: &str
queue_name: &str
credential: Arc<dyn TokenCredential>
options: Option<QueueClientOptions>
Result<Self>
endpoint
&self
&Url
queue_name
&self
&str
Queue Management
create
&self
options: Option<QueueClientCreateOptions<'_>>
Result<Response<(), NoFormat>>
create_if_not_exists
&self
options: Option<QueueClientCreateOptions<'_>>
Result<Response<(), NoFormat>>
delete
&self
options: Option<QueueClientDeleteOptions<'_>>
Result<Response<(), NoFormat>>
delete_if_exists
&self
options: Option<QueueClientDeleteOptions<'_>>
Result<Response<(), NoFormat>>
exists
&self
Result<bool>
clear
&self
options: Option<QueueClientClearOptions<'_>>
Result<Response<(), NoFormat>>
Metadata Operations
set_metadata
&self
options: Option<QueueClientSetMetadataOptions<'_>>
Result<Response<(), NoFormat>>
get_metadata
&self
options: Option<QueueClientGetMetadataOptions<'_>>
Result<Response<QueueClientGetMetadataResult, NoFormat>>
Message Operations
enqueue_message
&self
message: &str
options: Option<QueueClientEnqueueOptions<'_>>
Result<Response<Option<EnqueuedMessage>, XmlFormat>>
dequeue_message
&self
options: Option<QueueClientDequeueOptions<'_>>
Result<Response<Option<DequeuedMessage>, XmlFormat>>
dequeue_messages
&self
options: Option<QueueClientDequeueOptions<'_>>
Result<Response<ListOfDequeuedMessage, XmlFormat>>
peek_message
&self
options: Option<QueueClientPeekOptions<'_>>
Result<Response<Option<PeekedMessage>, XmlFormat>>
peek_messages
&self
options: Option<QueueClientPeekOptions<'_>>
Result<Response<ListOfPeekedMessage, XmlFormat>>
delete_message
&self
message_id: &str
pop_receipt: &str
options: Option<QueueClientDeleteMessageOptions<'_>>
Result<Response<(), NoFormat>>
update_message
&self
message_id: &str
pop_receipt: &str
visibility_timeout: i32
options: Option<QueueClientUpdateOptions<'_>>
Result<Response<(), NoFormat>>
Access Policy Operations
get_access_policy
&self
options: Option<QueueClientGetAccessPolicyOptions<'_>>
Result<Response<ListOfSignedIdentifier, XmlFormat>>
set_access_policy
&self
queue_acl: RequestContent<ListOfSignedIdentifier>
options: Option<QueueClientSetAccessPolicyOptions<'_>>
Result<Response<QueueClientSetAccessPolicyResult, NoFormat>>
Examples of how to use each method has been provided in the
sdk/storage/examples/queue_client.rs
file.Recorded tests has also been pushed to the repo
Azure/azure-sdk-assets
and theassets.json
updated.The client is generated using tsp-client using remote
Azure/azure-rest-api-specs
repo.